goselect icon indicating copy to clipboard operation
goselect copied to clipboard

Doesn't work on Windows

Open walles opened this issue 1 year ago • 4 comments

Seems like Goselect doesn't work on Windows.

  • If I understood @creack correctly, tests are failing on Windows: https://github.com/creack/goselect/pull/21#issuecomment-2200040823
  • When I tried on Windows in a real program I ran into what looks exactly like what the tests show: https://github.com/walles/moar/issues/222

Seems like Select() just falls through on Windows without waiting.

Here's one repro, from the PR mentioned above. Other tests are failing on Windows as well:

func TestSelect_readEmptyPipe(t *testing.T) {
	r, w, err := os.Pipe()
	if err != nil {
		t.Fatal(err)
	}
	defer func() {
		if err := w.Close(); err != nil {
			t.Fatal(err)
		}
		if err := r.Close(); err != nil {
			t.Fatal(err)
		}
	}()

	rFDSet := &FDSet{}
	rFDSet.Set(r.Fd())
	max := r.Fd()
	if err := Select(int(max+1), rFDSet, nil, nil, 10*time.Millisecond); err != nil {
		t.Fatalf("select call failed: %s", err)
	}

	if rFDSet.IsSet(r.Fd()) {
		t.Fatal("Nothing written, the pipe should not have been ready for reading")
	}
}

walles avatar Jul 10 '24 05:07 walles

Is it an issue with the lib or an issue with the syscall?

Guillaume J. Charmes

On Wed, Jul 10, 2024 at 6:24 AM Johan Walles @.***> wrote:

Seems like Goselect doesn't work on Windows.

Seems like Select() just falls through on Windows without waiting.

Here's one repro https://github.com/creack/goselect/pull/21/files#diff-0623581372341a487293eded22614f1f5ce3c5ff78988e0391b5bb4edddf9d62R62-R86, from the PR mentioned above. Other tests are failing on Windows as well:

func TestSelect_readEmptyPipe(t *testing.T) { r, w, err := os.Pipe() if err != nil { t.Fatal(err) } defer func() { if err := w.Close(); err != nil { t.Fatal(err) } if err := r.Close(); err != nil { t.Fatal(err) } }()

rFDSet := &FDSet{} rFDSet.Set(r.Fd()) max := r.Fd() if err := Select(int(max+1), rFDSet, nil, nil, 10*time.Millisecond); err != nil { t.Fatalf("select call failed: %s", err) }

if rFDSet.IsSet(r.Fd()) { t.Fatal("Nothing written, the pipe should not have been ready for reading") } }

— Reply to this email directly, view it on GitHub https://github.com/creack/goselect/issues/22, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7LZITQO2TDG4QFVUDZ7LZLTAQVAVCNFSM6AAAAABKUEGZJOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM4TSNZYGA3TCNY . You are receiving this because you were mentioned.Message ID: @.***>

creack avatar Jul 10 '24 08:07 creack

Are the tests correct? Or are they using the library the wrong way?

Also, the example, do you know whether that works on Windows? https://github.com/creack/goselect/blob/master/example/main.go

Is it an issue with the lib or an issue with the syscall?

I don't think I understand your question...

Both the tests and moar are using github.com/creack/goselect as documented (?).

On macOS and Linux this works as I'd expect.

On Windows it does not.

I can see some possibilities:

  • The tests are wrong. Then the tests should be fixed or replaced.
  • The tests are correct, but the library does not work as advertised. Then the library should be fixed.

Not sure if this clears anything up?

walles avatar Jul 10 '24 09:07 walles

The lib is a thin wrapper on top of the go stdlib syscall.Select. It may be an issue with the go implementation of that syscall on windows

-- Guillaume J. Charmes

On Wed, Jul 10, 2024 at 10:38 AM Johan Walles @.***> wrote:

Are the tests correct? Or are they using the library the wrong way?

Also, the example, do you know whether that works on Windows? https://github.com/creack/goselect/blob/master/example/main.go

Is it an issue with the lib or an issue with the syscall?

I don't think I understand your question...

Both the tests and moar are using github.com/creack/goselect as documented (?).

On macOS and Linux this works as I'd expect.

On Windows it does not.

I can see some possibilities:

  • The tests are wrong. Then the tests should be fixed or replaced.
  • The tests are correct, but the library does not work as advertised. Then the library should be fixed.

Not sure if this clears anything up?

— Reply to this email directly, view it on GitHub https://github.com/creack/goselect/issues/22#issuecomment-2220028465, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7LZIQLFM2QZ5RL52WINLZLT6J7AVCNFSM6AAAAABKUEGZJOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRQGAZDQNBWGU . You are receiving this because you were mentioned.Message ID: @.***>

creack avatar Jul 10 '24 10:07 creack

If you could provide some example code showing how Goselect works on Windows that would be super!

The README.md says Windows is tested and supported, but I just don't understand how.

walles avatar Jul 11 '24 16:07 walles