On Wed, 10 Nov 2021 08:48:22 +0900 Takashi Yano wrote: > On Wed, 10 Nov 2021 08:29:32 +0900 > Takashi Yano wrote: > > On Wed, 10 Nov 2021 08:22:45 +0900 > > Takashi Yano wrote: > > > On Tue, 9 Nov 2021 09:11:28 -0500 > > > Ken Brown wrote: > > > > I'll have to reproduce the hang myself in order to test this (or maybe > > > > you could > > > > test it), but I now have a new guess: If the read call above keeps > > > > failing with > > > > EINTR, then we're in an infinite loop. This could happen because of > > > > the > > > > following code in fhandler_pipe::raw_read: > > > > > > > > DWORD waitret = cygwait (read_mtx, timeout); > > > > switch (waitret) > > > > { > > > > case WAIT_OBJECT_0: > > > > break; > > > > case WAIT_TIMEOUT: > > > > set_errno (EAGAIN); > > > > len = (size_t) -1; > > > > return; > > > > default: > > > > set_errno (EINTR); > > > > len = (size_t) -1; > > > > return; > > > > } > > > > > > > > Takashi, is EINTR really the appropriate errno in the default case? > > > > Isn't > > > > cygwait supposed to handle signals? > > > > > > I assume cygwait() returns WAIT_SIGNALED when signalled > > > by SIGINT, SIGTERM, SIGTSTP, etc... In this case, EINTR > > > should return I think. > > > > > > Is it wrong? > > > > Ah, if SA_RESTART is set, we should continue to read even > > if signalled... > > So, should this be like following? > > restart_wait_read_mtx: > DWORD waitret = cygwait (read_mtx, timeout, cw_sig_eintr); > switch (waitret) > { > case WAIT_OBJECT_0: > break; > case WAIT_TIMEOUT: > set_errno (EAGAIN); > len = (size_t) -1; > return; > case WAIT_SIGNALED: > if (_my_tls.call_signal_handler ()) > goto restart_wait_read_mtx; > set_errno (EINTR); > len = (size_t) -1; > return; > default: > /* Should not reach here. */ > __seterrno (); > len = (size_t) -1; > return; > }
No, we don't have to do that because cygwait() do the same internally. cygwain() returns WAIT_SIGNALED when signalled only if SA_RESTART is not set. So, the current code LGTM. -- 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