Pthreads – some FAQs

  • Q: What happens in a multithreaded process when a thread calls one of the exec*() routines? A: The calling application (the predecessor) is completely replaced by the successor process, which will be only the thread that called exec. Note that no TSD destructors or thread-cleanup handlers are called.
  • Q: What happens in a multithreaded process when a thread calls fork(2)? A: It's OS-dependent. On modern Linux, only the thread that called fork(2) is replicated in the new child process. All other threads that existed prior to the fork are gone. No TSD destructors or thread cleanup handlers are called. Calling fork in a multithreaded application can lead to difficulties; it is not recommended. Find a link in the Further ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.