dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anders Kaseorg <andersk@MIT.EDU>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: dash@vger.kernel.org, git@packages.debian.org
Subject: Re: [PATCH] Set SA_RESTART flag on SIGCHLD handler
Date: Tue, 26 Jun 2012 06:03:51 -0400	[thread overview]
Message-ID: <4FE98907.4040507@mit.edu> (raw)
In-Reply-To: <4FE43C8C.2040809@mit.edu>

I wrote this greatly simplified skeleton of the failing Git test, and 
found that I can reproduce what looks like the same problem, fairly 
reliably:

$ rm -f fifo
$ mkfifo fifo
$ dash -c 'while echo -n .; do : < fifo & : > fifo; wait $!; done'
...............................dash: 1: cannot create fifo: Interrupted 
system call

After running this through strace, it seems clear what went wrong.  The 
parent’s open("fifo", O_WRONLY) is what causes the child’s open("fifo", 
O_RDONLY) to return.  If the child exits immediately, the parent may 
receive a SIGCHLD before its own open() returns.  Then when its SIGCHLD 
handler exits, open() returns EINTR.

That also explains why the SA_RESTART and restart-on-EINTR patches only 
turned it into a deadlock.  If the open() were restarted now, it would 
just block to wait for a _second_ reader of the FIFO, which will never 
arrive.

But if that’s what happened, it seems like a kernel bug to me! 
Shouldn’t an open() call only be restarted or return EINTR in the case 
that it hasn’t had any side effects yet and can safely be restarted?

Anders


  reply	other threads:[~2012-06-26 10:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4F665E77.3060102@mit.edu>
     [not found] ` <20120319025201.GA24778@burratino>
     [not found]   ` <4F66A6CA.4010002@mit.edu>
     [not found]     ` <20120319033751.GA25237@burratino>
2012-06-21  7:48       ` [PATCH] Set SA_RESTART flag on SIGCHLD handler Anders Kaseorg
     [not found]         ` <20120622003628.GD4730@burratino>
2012-06-22  9:36           ` Anders Kaseorg
2012-06-26 10:03             ` Anders Kaseorg [this message]
2012-06-26 12:19               ` Anders Kaseorg
2012-07-21 23:14                 ` Anders Kaseorg
2012-06-22 22:02           ` Jilles Tjoelker

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=4FE98907.4040507@mit.edu \
    --to=andersk@mit.edu \
    --cc=dash@vger.kernel.org \
    --cc=git@packages.debian.org \
    --cc=jrnieder@gmail.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 NNTP newsgroup(s).