Go to main content

Multithreaded Programming Guide

Exit Print View

Updated: March 2019
 
 

Special Issues for fork() and Oracle Solaris Threads

Prior to the Oracle Solaris 10 release, Oracle Solaris threads and POSIX threads defined the behavior of fork() differently. See Process Creation: exec and exit Issues for a thorough discussion of fork() issues.

Oracle Solaris libthread supported both fork() and fork1(). The fork() call has "fork-all" semantics. fork() duplicated everything in the process, including threads and LWPs, creating a true clone of the parent. The fork1() call created a clone that had only one thread. The process state and address space are duplicated, but only the calling thread was cloned.

POSIX libpthread supported only fork(), which has the same semantics as fork1() in Oracle Solaris threads.

Effective with the Oracle Solaris 10 release, you need not link against libthread or libpthread. The fork() function has the same semantics in both Oracle Solaris threads and POSIX threads. More specifically, fork1() semantics replicate only the caller. A new function, forkall(), is provided for those applications that require replicate-all semantics.

See Compiling and Linking a Multithreaded Program for more details.