tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pthread_atfork()/pthread_once()



Suppose I'm a library wanting to register a pthread_atfork handler. Contrary to 
what the function name might suggest, this makes perfect sense in a 
non-threaded environment. So pthread_atfork is available in libc.
Now, if I'm being called in a multithreaded environment, I should probably use 
pthread_once to register my handlers. However, pthread_once is only available 
in libpthread.
So what to do (other than linking against libpthread)? Is there a way to 
conditionally, based on whether the main program is single- or multithreaded, 
either call pthread_once or simply register the pthread_atfork handlers 
manually?


Home | Main Index | Thread Index | Old Index