[mythtv] Closing FDs before exec
mdz at debian.org
Thu Oct 21 05:09:34 UTC 2004
On Thu, Oct 21, 2004 at 01:00:53PM +1000, Christopher Pascoe wrote:
> A second way is to brute-force close all possible file descriptors in
> myth_system() after a fork but before calling system(). This has the
> advantage that it is race-free, catches all open filedescriptors now and
> in the future, but has the slight disadvantage of incurring a slightly
> increased penalty at fork time, and should there ever be a need to pass
> FDs via exec, then a mechanism will need to be introduced to do this.
> The attached myth_system.diff patch implements this.
This approach is simpler, and a few hundred system calls shouldn't make much
difference in the context of forking and executing a new program.
The value you want is sysconf(_SC_OPEN_MAX), rather than
More information about the mythtv-dev