[Bug 7898] ps doesn't handle SIGPIPE correctly

bugzilla at busybox.net bugzilla at busybox.net
Wed Mar 4 17:22:34 UTC 2015


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

--- Comment #9 from Denys Vlasenko <vda.linux at googlemail.com> 2015-03-04 17:22:32 UTC ---
Look, a horrible bug in coreutils cat:

$ strace cat </dev/zero | sleep 1
execve("/usr/bin/cat", ["cat"], [/* 52 vars */]) = 0
brk(0)                                  = 0x1071000
...
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=5851, si_uid=0} ---
+++ killed by SIGPIPE +++

Oh, check this out, bash is buggy:

$ yes '111111111111111111111111' | strace sh -c 'while read line; do echo
"$line"; done' | sleep 1
...
...
...
read(0, "1", 1)                         = 1
read(0, "1", 1)                         = 1
read(0, "\n", 1)                        = 1
write(1, "111111111111111111111111\n", 25) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=5872, si_uid=0} ---
+++ killed by SIGPIPE +++

$ Oops, a bug in GNU sed:

$ yes '111111111111111111111111' | strace sed 's/qwe/rty/' | sleep 1
execve("/usr/bin/sed", ["sed", "s/qwe/rty/"], [/* 52 vars */]) = 0
...
...
...
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f0a4a073000
read(0, "111\n111111111111111111111111\n111"..., 4096) = 4096
write(1, "111111111111111111111111\n1111111"..., 4096) = 4096
read(0, "1111111\n111111111111111111111111"..., 4096) = 4096
write(1, "111\n111111111111111111111111\n111"..., 4096) = 4096
read(0, "11111111111\n11111111111111111111"..., 4096) = 4096
write(1, "1111111\n111111111111111111111111"..., 4096) = 4096
read(0, "111111111111111\n1111111111111111"..., 4096) = 4096
write(1, "11111111111\n11111111111111111111"..., 4096) = 4096
read(0, "1111111111111111111\n111111111111"..., 4096) = 4096
write(1, "111111111111111\n1111111111111111"..., 4096) = 4096
read(0, "11111111111111111111111\n11111111"..., 4096) = 4096
write(1, "1111111111111111111\n111111111111"..., 4096) = 4096
read(0, "11\n111111111111111111111111\n1111"..., 4096) = 4096
write(1, "11111111111111111111111\n11111111"..., 4096) = 4096
read(0, "111111\n111111111111111111111111\n"..., 4096) = 4096
write(1, "11\n111111111111111111111111\n1111"..., 4096) = 4096
read(0, "1111111111\n111111111111111111111"..., 4096) = 4096
write(1, "111111\n111111111111111111111111\n"..., 4096) = 4096
read(0, "11111111111111\n11111111111111111"..., 4096) = 4096
write(1, "1111111111\n111111111111111111111"..., 4096) = 4096
read(0, "111111111111111111\n1111111111111"..., 4096) = 4096
write(1, "11111111111111\n11111111111111111"..., 4096) = 4096
read(0, "1111111111111111111111\n111111111"..., 4096) = 4096
write(1, "111111111111111111\n1111111111111"..., 4096) = 4096
read(0, "1\n111111111111111111111111\n11111"..., 4096) = 4096
write(1, "1111111111111111111111\n111111111"..., 4096) = 4096
read(0, "11111\n111111111111111111111111\n1"..., 4096) = 4096
write(1, "1\n111111111111111111111111\n11111"..., 4096) = 4096
read(0, "111111111\n1111111111111111111111"..., 4096) = 4096
write(1, "11111\n111111111111111111111111\n1"..., 4096) = 4096
read(0, "1111111111111\n111111111111111111"..., 4096) = 4096
write(1, "111111111\n1111111111111111111111"..., 4096) = 4096
read(0, "11111111111111111\n11111111111111"..., 4096) = 4096
write(1, "1111111111111\n111111111111111111"..., 4096) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=5886, si_uid=0} ---
+++ killed by SIGPIPE +++

Try grep, cut, fold, and dozens of other tools. They are all buggy. ;)

-- 
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