On Sun, 10 Mar 2024 17:38:53 +0900 Takashi Yano wrote: > On Sun, 10 Mar 2024 05:49:43 +0000 > wh wrote: > > Here's how to reproduce this behavior. > > > > In test3.pl: > > > > #!/usr/bin/perl > > my $wfds = ''; > > vec($wfds, fileno(STDOUT), 1) = 1; > > sleep 1; > > print STDERR "selecting\n"; > > select undef, $wfds, undef, undef; > > print STDERR "ready\n"; > > print "abc\n"; > > > > Then run: > > > > # curl is as shipped with Windows, /cygdrive/c/Windows/system32/curl > > ./test3.pl | (curl --version && cat) > > > > Expected result: > > > > curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN > > ... > > selecting > > ready > > abc > > > > Actual result: > > > > curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN > > ... > > selecting > > (hang) > > > > Using strace on perl, it ends with > > > > 95 332358 [main] perl 733 clock_nanosleep: clock_nanosleep (1.000000000) > > 1004437 1336795 [main] perl 733 clock_nanosleep: 0 = clock_nanosleep(1, 0, > > 1.000000000, 0.d) > > 247 1337042 [main] perl 733 time: 1710048216 = time(0x7FFFFCA00) > > 1010 1338052 [main] perl 733 fhandler_console::write: 0xA00051B10, 10 > > 822 1338874 [main] perl 733 fhandler_console::write: 10 = > > fhandler_console::write(...) > > 203 1339077 [main] perl 733 write: 10 = write(2, 0xA00051B10, 10) > > 254 1339331 [main] perl 733 pselect: pselect (8, 0x0, 0xA000330E0, 0x0, > > 0x0, 0x0) > > 207 1339538 [main] perl 733 pselect: to NULL, us -1 > > 490 1340028 [main] perl 733 dtable::select_write: fd 1 > > 191 1340219 [main] perl 733 select: sel.always_ready 0 > > --- Process 6888 (pid: 733) thread 784 created > > 859 1341078 [pipesel] perl 733 cygthread::stub: thread 'pipesel', id > > 0x310, stack_ptr 0x2BBCCB0 > > 192 1341270 [main] perl 733 select_stuff::wait: m 3, us > > 18446744073709551615, wmfo_timeout -1 > > 196 1341466 [pipesel] perl 733 SetThreadName: SetThreadDescription() > > failed. 00000000 10000000 > > > > Pipesel never comes back. > > > > Other info: > > > > - Replacing cat with tee (tee with no args is the same as cat) makes it > > work. tee reads in smaller chunks, while cat reads at the pipe buffer size. > > Comments in select.cc suggest this is important, but I don't understand it > > all. > > - Removing the curl makes it work > > - Using curl </dev/null to make curl not touch stdin makes it work > > - Using a Cygwin program instead of a non-Cygwin program e.g. id instead of > > curl makes it work > > - Removing the select confirms that nothing weird is breaking the pipe, and > > the "abc' shows up properly > > > > There was a report in MSYS2 > > https://github.com/msys2/msys2-runtime/issues/202 also about pipes to > > external programs, but there are some differences. In this scenario the > > non-Cygwin curl doesn't actually read anything from the pipe, and it should > > have exited before the select call. I tried a build of MSYS2 with their > > fix, and it still hangs in this way. > > Thanks for the report. I looked into this problem, and found the cause. > Let me consider how to fix that.
I have submitted the patch for this issue. Now it is waiting for the review. Thanks. -- Takashi Yano <takashi.y...@nifty.ne.jp> -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple