Multithreaded Programming Guide

Choosing Solaris or POSIX Threads

The Solaris implementation of Pthreads is completely compatible with Solaris threads. You can use both Solaris threads and Pthreads in the same application. See the pthreads(5) man page for a discussion of the differences between the thread implementations. See also Chapter 6, Programming With Solaris Threads in this manual for information about differences.

One difference between the thread types is the behavior of the fork functions.

In the Solaris 9 release, the behavior of the fork() function depended on whether or not the application was linked with the POSIX threads library. When linked with -lthread (Solaris Threads) but not linked with -lpthread (POSIX Threads), fork() would duplicate in the child thread all the threads from the parent process. When the application was linked with -lpthread, whether or not also linked with -lthread, fork() was the same as fork1() and only the calling thread is duplicated.

Starting in the Solaris 10 release, a call to the forkall() function replicates in the child process all of the threads in the parent process. A call to fork1() replicates only the calling thread in the child process. In the Solaris 10 release, a call to fork() is identical to a call to fork1(); only the calling thread is replicated in the child process. This is the POSIX-specified behavior for fork(). Applications that require replicate-all fork semantics must call forkall().