This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reading compressed character maps and gzip EPIPE issues.


On 11/24/19 3:25 AM, Andreas Schwab wrote:
> On Nov 23 2019, Carlos O'Donell wrote:
> 
>> So SIGPIPE is delivered, but gzip still writes the error message?
>> Why isn't gzip killed by the signal?
> 
> Because SIGPIPE is ignored.

Right.

1574310173.010698 rt_sigprocmask(SIG_BLOCK, NULL, ~[KILL STOP], 8) = 0
...
1574310173.011159 rt_sigaction(SIGPIPE, NULL, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=0}, 8) = 0

^^^ This is all being done by __spawni_child()

...
1574310173.012834 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
1574310173.012851 execve("/usr/lib64/qt-3.3/bin/gzip", ["gzip", "-cdq", "-"], 0x7ffc844ee480 /* 78 vars */) = -1 ENOENT (No such file or directory)
1574310173.012879 execve("/usr/share/Modules/bin/gzip", ["gzip", "-cdq", "-"], 0x7ffc844ee480 /* 78 vars */) = -1 ENOENT (No such file or directory)
1574310173.012902 execve("/usr/local/bin/gzip", ["gzip", "-cdq", "-"], 0x7ffc844ee480 /* 78 vars */) = -1 ENOENT (No such file or directory)
1574310173.012925 execve("/usr/bin/gzip", ["gzip", "-cdq", "-"], 0x7ffc844ee480 /* 78 vars */) = 0
...

136   sigset_t hset;
137   __sigprocmask (SIG_BLOCK, 0, &hset);
138   for (int sig = 1; sig < _NSIG; ++sig)
139     {
140       if ((attr->__flags & POSIX_SPAWN_SETSIGDEF)
141           && __sigismember (&attr->__sd, sig))
142         {
143           sa.sa_handler = SIG_DFL;
144         }
145       else if (__sigismember (&hset, sig))
146         {
147           if (__is_internal_signal (sig))
148             sa.sa_handler = SIG_IGN;
149           else
150             {
151               __libc_sigaction (sig, 0, &sa);
152               if (sa.sa_handler == SIG_IGN)
153                 continue;
154               sa.sa_handler = SIG_DFL;

We fetch the current handler and if it's SIG_IGN we leave it at SIG_IGN.

This matches what I expect from the POSIX requirements.

155             }
156         }
157       else
158         continue;
159 
160       __libc_sigaction (sig, &sa, 0);
161     }

Should localedef use POSIX_SPAWN_SETSIGDEF to set SIGPIPE to SIG_DFL
in the child (see locale/programs/charmap-dir.c:fopen_uncompressed)?

-- 
Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]