Messages in this thread | | | From | justinf@us ... | Date | Mon, 3 May 1999 22:52:59 -0400 | Subject | Re: FD_CLFORK or equivalent? |
| |
Alan Cox wrote:
>> Is there an existing Linux/Unix mechanism to force fds closed >> on fork() that I am unaware of? > >They exist only for exec - since within just a fork() the situation >is under your control. It is your fault if you forget to close() it - the >kernel isnt there to baby you - and if you want it to you can write a nice >fork wrapper that asks the library to close handles it is using.
Of course, when writing an application using pthreads you can make use of pthread_atfork() to register functions that will run in the parent before the fork, in the parent after the fork, and in the child after the fork. If you are writing a shared library with which other applications will be linked, this is an excellent way (the only way?) to perform cleanup when application threads fork().
Cheers,
Justin T. Fries IBM MQSeries Support Raleigh, North Carolina (919) 254-1422 TL 444-1422 Email: justinf@us.ibm.com
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |