#include <unistd.h>
unsigned alarm(unsigned sec);
Alarm requests are not stacked; successive calls reset the alarm clock of the calling process.
If sec is 0, any previously made alarm request is canceled.
fork(2) sets the alarm clock of a new process to 0. A process created by the exec family of routines inherits the time left on the old process’s alarm clock.
Calling alarm() in a multi-threaded process linked with -lthread (Solaris threads) and not with -lpthread (POSIX threads) currently behaves in the following fashion:
The above documents current behavior and the bugs are not going to be fixed since the above semantics are going to be discontinued in the next release.
The semantic for Solaris threads will move to the per-process semantic specified by POSIX at this future date. New applications should not rely on the per-thread semantic of alarm(), since this semantic will become obsolete.
In a process linked with -lpthread (whether or not it is also linked with -lthread), the semantics of alarm() are per-process, i.e. the resulting SIGALRM is sent to the process, and not necessarily to the calling thread. This semantic will be supported in the future.
This semantic is obtainable by simply linking with -lpthread. One can continue to use Solaris thread interfaces by linking with both -lpthread and -lthread.