This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFA: close-on-exec internal file descriptors
- From: Daniel Jacobowitz <drow at false dot org>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Sat, 6 Dec 2008 10:25:51 -0500
- Subject: Re: RFA: close-on-exec internal file descriptors
- References: <m3skp2w32i.fsf@fleche.redhat.com>
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