RFA: close-on-exec internal file descriptors

Daniel Jacobowitz drow@false.org
Sat Dec 6 15:26:00 GMT 2008


On Fri, Dec 05, 2008 at 05:38:13PM -0700, Tom Tromey wrote:
> +/* Like open, but ensure that the resulting file descriptor is marked
> +   close-on-exec, if possible.  */
> +int
> +open_cloexec (const char *path, int flags, int mode)
> +{
> +#ifdef O_CLOEXEC
> +  return open (path, flags | O_CLOEXEC, mode);

If you build with headers that include O_CLOEXEC support, but the
running kernel is too old, will this fail to open entirely?  Or are
unknown open flags ignored?

Also, WDYT about separating the goal from the mechanism?  With this
patch, every bit of gdb knows "we close file descriptors on exec";
if it was gdb_open, it would just be "gdb-specific version of open".

-- 
Daniel Jacobowitz
CodeSourcery



More information about the Gdb-patches mailing list