bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interrupted system call when using named pipes on FreeBSD


From: Chet Ramey
Subject: Re: interrupted system call when using named pipes on FreeBSD
Date: Fri, 18 Jan 2013 14:50:28 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 1/18/13 1:45 PM, Mike Frysinger wrote:
> On Friday 18 January 2013 07:55:00 Chet Ramey wrote:
>> On 1/18/13 1:30 AM, Mike Frysinger wrote:
>>> this is somewhat a continuation of this thread:
>>> http://lists.gnu.org/archive/html/bug-bash/2008-10/msg00091.html
>>>
>>> i've gotten more or less the same report in Gentoo:
>>> http://bugs.gentoo.org/447810
>>>
>>> the simple test case is:
>>> $ cat test.sh
>>> #!/bin/bash
>>> while :; do
>>>     (:)& (:)& (:)& (:)& (:)& (:)& (:)& (:)& (:)& (:)&
>>>     while read x ; do : ; done < <(echo foo)
>>> done
>>>
>>> execute `./test.sh` and we see failures pretty much all the time.
>>>
>>> a simple patch to workaround/fix the issue by Yuta SATOH:
>>> --- bash-4.2/redir.c
>>> +++ bash-4.2/redir.c
>>> @@ -632,7 +632,9 @@
>>>      }
>>>    else
>>>      {
>>> -      fd = open (filename, flags, mode);
>>> +      do {
>>> +   fd = open (filename, flags, mode);
>>> +      } while ((fd < 0) && (errno == EINTR));
>>>  #if defined (AFS)
>>>        if ((fd < 0) && (errno == EACCES))
>>>     {
>>>
>>> but we're not sure if this is the route to take ?  seems like if bash is
>>> handling SIGCHLD, there's no avoiding this sort of check.
>>
>> Why is open returning -1/EINTR when the SIGCHLD handler is installed with
>> SA_RESTART?  The intent is that opens get restarted even when bash handles
>> SIGCHLD.
> 
> i saw some signal() usage, but if it should all be using 
> sigaction/SA_RESTART, 
> i'll have them look along those lines to see if there are signals not being 
> registered correctly (or if the kernel sucks and isn't handling SA_RESTART 
> correctly).

SIGCHLD's not trapped, and there's no other signal that could be
interrupting the read, so it comes down to this code in sig.c:
set_signal_handler():

  /* We don't want a child death to interrupt interruptible system calls, even
     if we take the time to reap children */
#if defined (SIGCHLD)
  if (sig == SIGCHLD)
    act.sa_flags |= SA_RESTART;         /* XXX */
#endif

(I'm assuming MUST_REINSTALL_SIGHANDLERS isn't defined.)

Chet
- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlD5p4QACgkQu1hp8GTqdKuNWACdFbhEGsmuxikHreeRye3PAH7Y
xzYAn2uHNMhiDSn+FsQIRl3YCZGpR0jO
=R+OI
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]