[Bug 7898] ps doesn't handle SIGPIPE correctly

bugzilla at busybox.net bugzilla at busybox.net
Wed Mar 4 20:35:38 UTC 2015


https://bugs.busybox.net/show_bug.cgi?id=7898

--- Comment #11 from Denys Vlasenko <vda.linux at googlemail.com> 2015-03-04 20:35:37 UTC ---
(In reply to comment #10)
> (In reply to comment #9)
> 
> > Try grep, cut, fold, and dozens of other tools. They are all buggy. ;)
> 
> Seems that you have missed my point. In all your examples process get killed by
> SIGPIPE with *default* signal handler. However on Android system (at least on
> Android 5.0 and later) dynamic linker changes signal handler for SIGPIPE to
> 'debugger_signal_handler' function.

I have two arguments against it:

(1) I am not aware of any standards which allow libc init code or dynamic
linker to install a non-default SIGPIPE handler.

(2) Please tell me where do you see "cat" resetting SIGPIPE handler to default
here -

$ strace cat </dev/zero | sleep 1
execve("/usr/bin/cat", ["cat"], [/* 52 vars */]) = 0
brk(0)                                  = 0x61e000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f1fa65f1000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=91352, ...}) = 0
mmap(NULL, 91352, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1fa65da000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\34\2\0\0\0\0\0"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2101016, ...}) = 0
mmap(NULL, 3928640, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x7f1fa6012000
mprotect(0x7f1fa61c7000, 2097152, PROT_NONE) = 0
mmap(0x7f1fa63c7000, 24576, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b5000) = 0x7f1fa63c7000
mmap(0x7f1fa63cd000, 16960, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1fa63cd000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f1fa65d9000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f1fa65d7000
arch_prctl(ARCH_SET_FS, 0x7f1fa65d7740) = 0
mprotect(0x7f1fa63c7000, 16384, PROT_READ) = 0
mprotect(0x60a000, 4096, PROT_READ)     = 0
mprotect(0x7f1fa65f2000, 4096, PROT_READ) = 0
munmap(0x7f1fa65da000, 91352)           = 0
brk(0)                                  = 0x61e000
brk(0x63f000)                           = 0x63f000
brk(0)                                  = 0x63f000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=104789808, ...}) = 0
mmap(NULL, 104789808, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1f9fc22000
close(3)                                = 0
fstat(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fstat(0, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 5), ...}) = 0
fadvise64(0, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
65536) = 65536
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
65536) = 65536
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
65536) = 65536
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
65536) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=8155, si_uid=0} ---
+++ killed by SIGPIPE +++

Do you see a sigaction syscall anywhere in the listing?
I don't.
It means that coreutils cat does not do anything like "I need to set SIGPIPE to
SIG_DFL".

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list