public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: Another pipe-related problem?
Date: Wed, 10 Nov 2021 09:16:13 +0900	[thread overview]
Message-ID: <20211110091613.26a636e789fe36a098412f1b@nifty.ne.jp> (raw)
In-Reply-To: <20211110084822.fa32acb567bd26ab43c393bd@nifty.ne.jp>

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.yano@nifty.ne.jp>

  reply	other threads:[~2021-11-10  0:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08 13:12 Henry S. Thompson
2021-11-08 14:35 ` Ken Brown
2021-11-08 18:52   ` Ken Brown
2021-11-09 10:55   ` Henry S. Thompson
2021-11-09 14:11     ` Ken Brown
2021-11-09 14:47       ` Henry S. Thompson
2021-11-09 22:16       ` Ken Brown
2021-11-09 22:20         ` Ken Brown
2021-11-10  2:53           ` Ken Brown
2021-11-10  3:51             ` Backwoods BC
2021-11-10 14:47             ` Ken Brown
2021-11-10 17:23               ` Henry S. Thompson
2021-11-10 18:03                 ` Ken Brown
2021-11-10 18:42                   ` Henry S. Thompson
2021-11-10 23:07                     ` Andrey Repin
2021-11-11 11:06                       ` Andrey Repin
2021-11-11 14:16                     ` Ken Brown
2021-12-08 21:09                     ` XEmacs versus Cygwin 3.3 (was Re: Another pipe-related problem?) Henry S. Thompson
2021-12-09  8:39                       ` Aidan Kehoe
2021-11-09 23:22       ` Another pipe-related problem? Takashi Yano
2021-11-09 23:29         ` Takashi Yano
2021-11-09 23:48           ` Takashi Yano
2021-11-10  0:16             ` Takashi Yano [this message]
2021-11-10  0:37               ` Takashi Yano
2021-11-10  2:02                 ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211110091613.26a636e789fe36a098412f1b@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).