]> granicus.if.org Git - strace/commit
Close stdin/out after child is forked
authorDenys Vlasenko <dvlasenk@redhat.com>
Mon, 8 Feb 2016 13:52:32 +0000 (14:52 +0100)
committerDenys Vlasenko <dvlasenk@redhat.com>
Mon, 8 Feb 2016 17:17:38 +0000 (18:17 +0100)
commitc9f85b38766a0e14f4f035f6d702fe57b6b9110c
treef9a3076f725d0077e01a33f6a47339a5216adc2c
parent7469e252fa89935970701cf05460ce6c3c72b46d
Close stdin/out after child is forked

Testcase:

{ sleep 1; yes | head -n99999; } | strace -o/dev/null sh -c 'exec <&-; sleep 9'

The writer (head) will be able to perform writes to write end of the pipe.
With strace call removed, head will immediately get SIGPIPE.

This change fixes this: now writer immediately gets SIGPIPE with strace too.

* strace.c (startup_child): Close stdin/out and reopen them to /dev/null.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
strace.c