Third-party libraries
Posted Aug 27, 2009 21:51 UTC (Thu) by
giraffedata (subscriber, #1954)
In reply to:
Third-party libraries by quotemstr
Parent article:
In brief
I don't see it. Never mind pthread_atfork() -- after all, the issue is exec, not fork. The alternative to O_CLOEXEC for a library that opens files under the covers would seem to be a prepare_for_exec() function exported by the library. The user makes sure he calls that before any exec().
As for the multithreaded program, it already has to serialize access to these file-descriptor-using functions anyway (you wouldn't want two threads opening that file at the same time), so it might as well synchronize prepare_for_exec() with those. This serialization could be done either in the library (i.e. the library is thread-safe), or outside.
Oh, and here comes pthread_atfork(): it can make sure the serialization mechanism survives a fork that may precede the exec.
(
Log in to post comments)