[PATCH] Avoid inheriting *.stdout and *.stderr into every child process

Andrew Bartlett abartlet at samba.org
Mon Aug 27 10:12:06 UTC 2018

On Mon, 2018-08-27 at 12:08 +0200, Stefan Metzmacher wrote:
> Hi Andrew,
> doesn't this mean we'll loose the debug output of those processes?
> metze

I don't think so.  This is about what is passed in, because the python
FDs are (sadly) not close-on-exec.  

The correct files (or /dev/null for stdin) are attached to the correct
child via the stdin/stdout/stderr parameters, but the un-referenced
files that just happen to be in an FD slot are closed.

The problem is, and I'm happy to clarify the message, that every
*other* .stderr and .stdout file previously opened in the script was
also passed in, on a random high FD, by virtue of the fork()

I hope this clarifies,

Andrew Bartlett

Andrew Bartlett                       http://samba.org/~abartlet/
Authentication Developer, Samba Team  http://samba.org
Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba

More information about the samba-technical mailing list