HomeFreeBSD

Ensure zed _finish_daemonize() leaves fds 0-2 open

Description

Ensure zed _finish_daemonize() leaves fds 0-2 open

In zed's _finish_daemonize(), /dev/null is open()d onto a temporary
file descriptor which is then dup()d onto stdin, stdout, and stderr.
But if file descriptors 0, 1, or 2 are not already open at the start
of this function, then the temporary file descriptor will fall within
this range and be inadvertently closed when the function cleans up.

This commit adds a check to prevent inadvertently closing this
(presumably temporary) file descriptor when it shouldn't.

Signed-off-by: Chris Dunlap <cdunlap@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4384

Details

Provenance
Chris Dunlap <cdunlap@llnl.gov>Authored on Mar 1 2016, 8:23 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Mar 9 2016, 1:46 AM
Parents
rG272be6834c39: Fix zpool iostat bandwidth/ops calculation
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG048bb5bd4950: Ensure zed _finish_daemonize() leaves fds 0-2 open (authored by Chris Dunlap <cdunlap@llnl.gov>).Mar 9 2016, 1:46 AM