[patch] Minor O_CLOEXEC optimization, "regression" fix

Eli Zaretskii eliz@gnu.org
Wed Oct 9 17:07:00 GMT 2013


> Date: Wed, 9 Oct 2013 09:34:17 -0400 (EDT)
> From: Kai Tietz <ktietz@redhat.com>
> Cc: gdb-patches@sourceware.org, Tom Tromey <tromey@redhat.com>
> 
> > May one rely on MS-Windows fopen("","re") will fail with EINVAL if it fails
> > because of the "e" flag, Kai?  It is in GDB function gdb_fopen_cloexec.
> 
> Yes, it fails due the 'e' command in mode.  Obviously this option isn't supported on Windows due there is no fork.

What does this have to do with fork?  Windows does know how to start
child processes, so I think making the handle not inherited is the
proper equivalent on Windows.

Latest runtime libraries have the non-standard 'N' flag.
Alternatively, one can make the handle non-inheritable after opening
the file, by using a Win32 API.

> So yes, probing for EINVAL seems to me like a valid way to probe for valid arguments here.

As I wrote earlier, this is not a good idea, as GDB will likely crash
on latest Windows versions due to invalid parameter handling in the
library.



More information about the Gdb-patches mailing list