This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: close-on-exec internal file descriptors


>>>>> "Mark" == Mark Kettenis <mark.kettenis@xs4all.nl> writes:

Tom> I chose to take advantage of the new glibc flags like O_CLOEXEC when
Tom> they are available.  This is friendlier in the Python case -- here,
Tom> gdb might have multiple threads, and the glibc flags enable us to
TOM> avoid a window where a file descriptor is not marked close-on-exec.

Mark> Sorry, but I don't see the point in having #ifdef O_CLOEXEC code
Mark> when there is a perfectly portable way to do this using fcntl.

It is better for thread safety.  This matters in the Python case.

Mark> It leads to more bits of code that can possibly go untested.

I will try to add a test case.  That will address this.

Mark> I also think it would actually be better to explicitly close file
Mark> descriptors before doing an exec instead of relying on people to use
Mark> the proper _cloexec call throughout gdb.

Why do you think this?

I think that it is difficult to truly ensure reliability with either
approach.  We might miss an open, but so too we might miss a
fork/exec.  The more libraries we use, the more likely this becomes.

But, since gdb and all its dependencies are free software, I think we
might as well try to implement the better approach, whichever that is.
In my view, close-on-exec is preferable.  It better communicates the
intent of the programmer, and in the library case it is an abstraction
barrier.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]