|Skip Navigation Links|
|Exit Print View|
|Multithreaded Programming Guide Oracle Solaris 11.1 Information Library|
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.
Whether fork() has “fork-all” semantics or “fork-one” semantics was dependent on which library is used. Link with -lthread to assign “fork-all” semantics to fork(). Link with -lpthread to assign “fork-one” semantics to fork().
Effective with the Oracle Solaris 10 release, fork() 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.