lkml.org 
[lkml]   [1999]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: 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/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.024 / U:1.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site