Multithreaded Programming Guide

Special Issues for fork() and Solaris Threads

Solaris threads and POSIX threads define the behavior of fork() differently. See "Process Creation--exec(2)and exit(2) Issues" for a thorough discussion of fork() issues.

Solaris libthread supports both fork() and fork1(). The fork() call has "fork-all" semantics--it duplicates everything in the process, including threads and LWPs, creating a true clone of the parent. The fork1() call creates a clone that has only one thread; the process state and address space are duplicated, but only the calling thread is cloned.

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

Whether fork() has "fork-all" semantics or "fork-one" semantics is dependent on which library is used. Linking with -lthread assigns "fork-all" semantics to fork(), while linking with -lpthread assigns "fork-one" semantics to fork().

See "Linking With libthread or libpthread" for more details.