source: rtems-docs/posix_users/signal.rst @ fa70fd2

4.115
Last change on this file since fa70fd2 was fa70fd2, checked in by Chris Johns <chrisj@…>, on 02/26/16 at 07:22:07

POSIX User clean up.

  • Property mode set to 100644
File size: 24.9 KB
Line 
1.. COMMENT: COPYRIGHT (c) 1988-2002.
2.. COMMENT: On-Line Applications Research Corporation (OAR).
3.. COMMENT: All rights reserved.
4
5Signal Manager
6##############
7
8Introduction
9============
10
11The signal manager provides the functionality associated with the generation,
12delivery, and management of process-oriented signals.
13
14The directives provided by the signal manager are:
15
16- sigaddset_ - Add a Signal to a Signal Set
17
18- sigdelset_ - Delete a Signal from a Signal Set
19
20- sigfillset_ - Fill a Signal Set
21
22- sigismember_ - Is Signal a Member of a Signal Set
23
24- sigemptyset_ - Empty a Signal Set
25
26- sigaction_ - Examine and Change Signal Action
27
28- pthread_kill_ - Send a Signal to a Thread
29
30- sigprocmask_ - Examine and Change Process Blocked Signals
31
32- pthread_sigmask_ - Examine and Change Thread Blocked Signals
33
34- kill_ - Send a Signal to a Process
35
36- sigpending_ - Examine Pending Signals
37
38- sigsuspend_ - Wait for a Signal
39
40- pause_ - Suspend Process Execution
41
42- sigwait_ - Synchronously Accept a Signal
43
44- sigwaitinfo_ - Synchronously Accept a Signal
45
46- sigtimedwait_ - Synchronously Accept a Signal with Timeout
47
48- sigqueue_ - Queue a Signal to a Process
49
50- alarm_ - Schedule Alarm
51
52- ualarm_ - Schedule Alarm in Microseconds
53
54Background
55==========
56
57Signals
58-------
59
60POSIX signals are an asynchronous event mechanism.  Each process and thread has
61a set of signals associated with it.  Individual signals may be enabled
62(e.g. unmasked) or blocked (e.g. ignored) on both a per-thread and process
63level.  Signals which are enabled have a signal handler associated with them.
64When the signal is generated and conditions are met, then the signal handler is
65invoked in the proper process or thread context asynchronous relative to the
66logical thread of execution.
67
68If a signal has been blocked when it is generated, then it is queued and kept
69pending until the thread or process unblocks the signal or explicitly checks
70for it.  Traditional, non-real-time POSIX signals do not queue.  Thus if a
71process or thread has blocked a particular signal, then multiple occurrences of
72that signal are recorded as a single occurrence of that signal.
73
74.. COMMENT: TODO: SIGRTMIN and SIGRTMAX ?
75
76One can check for the set of outstanding signals that have been blocked.
77Services are provided to check for outstanding process or thread directed
78signals.
79
80Signal Delivery
81---------------
82
83Signals which are directed at a thread are delivered to the specified thread.
84
85Signals which are directed at a process are delivered to a thread which is
86selected based on the following algorithm:
87
88#. If the action for this signal is currently ``SIG_IGN``, then the signal is
89   simply ignored.
90
91#. If the currently executing thread has the signal unblocked, then the signal
92   is delivered to it.
93
94#. If any threads are currently blocked waiting for this signal
95   (``sigwait()``), then the signal is delivered to the highest priority thread
96   waiting for this signal.
97
98#. If any other threads are willing to accept delivery of the signal, then the
99   signal is delivered to the highest priority thread of this set. In the
100   event, multiple threads of the same priority are willing to accept this
101   signal, then priority is given first to ready threads, then to threads
102   blocked on calls which may be interrupted, and finally to threads blocked on
103   non-interruptible calls.
104
105#. In the event the signal still can not be delivered, then it is left
106   pending. The first thread to unblock the signal (``sigprocmask()`` or
107   ``pthread_sigprocmask()``) or to wait for this signal (``sigwait()``) will
108   be the recipient of the signal.
109
110Operations
111==========
112
113Signal Set Management
114---------------------
115
116Each process and each thread within that process has a set of individual
117signals and handlers associated with it.  Services are provided to construct
118signal sets for the purposes of building signal sets - type ``sigset_t`` - that
119are used to provide arguments to the services that mask, unmask, and check on
120pending signals.
121
122Blocking Until Signal Generation
123--------------------------------
124
125A thread may block until receipt of a signal.  The "sigwait" and "pause"
126families of functions block until the requested signal is received or if using
127``sigtimedwait()`` until the specified timeout period has elapsed.
128
129Sending a Signal
130----------------
131
132This is accomplished via one of a number of services that sends a signal to
133either a process or thread.  Signals may be directed at a process by the
134service ``kill()`` or at a thread by the service ``pthread_kill()``
135
136Directives
137==========
138
139This section details the signal manager's directives.  A subsection is
140dedicated to each of this manager's directives and describes the calling
141sequence, related constants, usage, and status codes.
142
143.. _sigaddset:
144
145sigaddset - Add a Signal to a Signal Set
146----------------------------------------
147.. index:: sigaddset
148.. index:: add a signal to a signal set
149
150**CALLING SEQUENCE:**
151
152.. code-block:: c
153
154    #include <signal.h>
155    int sigaddset(
156        sigset_t *set,
157        int       signo
158    );
159
160**STATUS CODES:**
161
162The function returns 0 on success, otherwise it returns -1 and sets ``errno``
163to indicate the error. ``errno`` may be set to:
164
165.. list-table::
166 :class: rtems-table
167
168 * - ``EINVAL``
169   - Invalid argument passed.
170
171**DESCRIPTION:**
172
173This function adds the signal ``signo`` to the specified signal ``set``.
174
175**NOTES:**
176
177The set must be initialized using either ``sigemptyset`` or ``sigfillset``
178before using this function.
179
180.. _sigdelset:
181
182sigdelset - Delete a Signal from a Signal Set
183---------------------------------------------
184.. index:: sigdelset
185.. index:: delete a signal from a signal set
186
187**CALLING SEQUENCE:**
188
189.. code-block:: c
190
191    #include <signal.h>
192    int sigdelset(
193        sigset_t *set,
194        int       signo
195    );
196
197**STATUS CODES:**
198
199The function returns 0 on success, otherwise it returns -1 and sets ``errno``
200to indicate the error. ``errno`` may be set to:
201
202.. list-table::
203 :class: rtems-table
204
205 * - ``EINVAL``
206   - Invalid argument passed.
207
208**DESCRIPTION:**
209
210This function deletes the signal specified by ``signo`` from the specified
211signal ``set``.
212
213**NOTES:**
214
215The set must be initialized using either ``sigemptyset`` or ``sigfillset``
216before using this function.
217
218.. _sigfillset:
219
220sigfillset - Fill a Signal Set
221------------------------------
222.. index:: sigfillset
223.. index:: fill a signal set
224
225**CALLING SEQUENCE:**
226
227.. code-block:: c
228
229    #include <signal.h>
230    int sigfillset(
231        sigset_t *set
232    );
233
234**STATUS CODES:**
235
236The function returns 0 on success, otherwise it returns -1 and sets ``errno``
237to indicate the error. ``errno`` may be set to:
238
239.. list-table::
240 :class: rtems-table
241
242 * - ``EINVAL``
243   - Invalid argument passed.
244
245**DESCRIPTION:**
246
247This function fills the specified signal ``set`` such that all signals are set.
248
249.. _sigismember:
250
251sigismember - Is Signal a Member of a Signal Set
252------------------------------------------------
253.. index:: sigismember
254.. index:: is signal a member of a signal set
255
256**CALLING SEQUENCE:**
257
258.. code-block:: c
259
260    #include <signal.h>
261    int sigismember(
262        const sigset_t *set,
263        int             signo
264    );
265
266**STATUS CODES:**
267
268The function returns either 1 or 0 if completed successfully, otherwise it
269returns -1 and sets ``errno`` to indicate the error. ``errno`` may be set to:
270
271.. list-table::
272 :class: rtems-table
273
274 * - ``EINVAL``
275   - Invalid argument passed.
276
277**DESCRIPTION:**
278
279This function returns returns 1 if ``signo`` is a member of ``set`` and 0
280otherwise.
281
282**NOTES:**
283
284The set must be initialized using either ``sigemptyset`` or ``sigfillset``
285before using this function.
286
287.. _sigemptyset:
288
289sigemptyset - Empty a Signal Set
290--------------------------------
291.. index:: sigemptyset
292.. index:: empty a signal set
293
294**CALLING SEQUENCE:**
295
296.. code-block:: c
297
298    #include <signal.h>
299    int sigemptyset(
300        sigset_t *set
301    );
302
303**STATUS CODES:**
304
305The function returns 0 on success, otherwise it returns -1 and sets ``errno``
306to indicate the error. ``errno`` may be set to:
307
308.. list-table::
309 :class: rtems-table
310
311 * - ``EINVAL``
312   - Invalid argument passed.
313
314**DESCRIPTION:**
315
316This function initializes an empty signal set pointed to by ``set``.
317
318.. _sigaction:
319
320sigaction - Examine and Change Signal Action
321--------------------------------------------
322.. index:: sigaction
323.. index:: examine and change signal action
324
325**CALLING SEQUENCE:**
326
327.. code-block:: c
328
329    #include <signal.h>
330    int sigaction(
331        int                     sig,
332        const struct sigaction *act,
333        struct sigaction       *oact
334    );
335
336**STATUS CODES:**
337
338The function returns 0 on success, otherwise it returns -1 and sets ``errno``
339to indicate the error. ``errno`` may be set to:
340
341.. list-table::
342 :class: rtems-table
343
344 * - ``EINVAL``
345   - Invalid argument passed.
346 * - ``ENOTSUP``
347   - Realtime Signals Extension option not supported.
348
349**DESCRIPTION:**
350
351If the argument act is not a null pointer, it points to a structure specifying
352the action to be associated with the specified signal. If the argument oact is
353not a null pointer, the action previously associated with the signal is stored
354in the location pointed to by the argument oact. If the argument act is a null
355pointer, signal handling is unchanged; thus, the call can be used to enquire
356about the current handling of a given signal.
357
358The structure ``sigaction`` has the following members:
359
360.. list-table::
361 :class: rtems-table
362
363 * - ``void(*)(int) sa_handler``
364   - Pointer to a signal-catching function or one of the macros SIG_IGN or
365     SIG_DFL.
366 * - ``sigset_t sa_mask``
367   - Additional set of signals to be blocked during execution of
368     signal-catching function.
369 * - ``int sa_flags``
370   - Special flags to affect behavior of signal.
371 * - ``void(*)(int, siginfo_t*, void*) sa_sigaction``
372   - Alternative pointer to a signal-catching function.
373
374``sa_handler`` and ``sa_sigaction`` should never be used at the same time as
375their storage may overlap.
376
377If the ``SA_SIGINFO`` flag (see below) is set in ``sa_flags``, the
378``sa_sigaction`` field specifies a signal-catching function,
379otherwise``sa_handler`` specifies the action to be associated with the signal,
380which may be a signal-catching function or one of the macros ``SIG_IGN`` or
381``SIG_DFN``.
382
383The following flags can be set in the ``sa_flags`` field:
384
385.. list-table::
386 :class: rtems-table
387
388 * - ``SA_SIGINFO``
389   - If not set, the signal-catching function should be declared as ``void
390     func(int signo)`` and the address of the function should be set
391     in``sa_handler``.  If set, the signal-catching function should be declared
392     as ``void func(int signo, siginfo_t* info, void* context)`` and the
393     address of the function should be set in ``sa_sigaction``.
394
395The prototype of the ``siginfo_t`` structure is the following:
396
397.. code-block:: c
398
399    typedef struct
400    {
401        int si_signo;        /* Signal number */
402        int si_code;         /* Cause of the signal */
403        pid_t si_pid;        /* Sending process ID */
404        uid_t si_uid;        /* Real user ID of sending process */
405        void* si_addr;       /* Address of faulting instruction */
406        int si_status;       /* Exit value or signal */
407        union sigval
408        {
409            int sival_int;   /* Integer signal value */
410            void* sival_ptr; /* Pointer signal value */
411        } si_value;          /* Signal value */
412    }
413
414**NOTES:**
415
416The signal number cannot be SIGKILL.
417
418.. _pthread_kill:
419
420pthread_kill - Send a Signal to a Thread
421----------------------------------------
422.. index:: pthread_kill
423.. index:: send a signal to a thread
424
425**CALLING SEQUENCE:**
426
427.. code-block:: c
428
429    #include <signal.h>
430    int pthread_kill(
431        pthread_t thread,
432        int       sig
433    );
434
435**STATUS CODES:**
436
437The function returns 0 on success, otherwise it returns -1 and sets ``errno`` to
438indicate the error. ``errno`` may be set to:
439
440.. list-table::
441 :class: rtems-table
442
443 * - ``ESRCH``
444   - The thread indicated by the parameter thread is invalid.
445 * - ``EINVAL``
446   - Invalid argument passed.
447
448**DESCRIPTION:**
449
450This functions sends the specified signal ``sig`` to a thread referenced to by
451``thread``.
452
453If the signal code is ``0``, arguments are validated and no signal is sent.
454
455.. _sigprocmask:
456
457sigprocmask - Examine and Change Process Blocked Signals
458--------------------------------------------------------
459.. index:: sigprocmask
460.. index:: examine and change process blocked signals
461
462**CALLING SEQUENCE:**
463
464.. code-block:: c
465
466    #include <signal.h>
467    int sigprocmask(
468        int             how,
469        const sigset_t *set,
470        sigset_t       *oset
471    );
472
473**STATUS CODES:**
474
475The function returns 0 on success, otherwise it returns -1 and sets ``errno``
476to indicate the error. ``errno`` may be set to:
477
478.. list-table::
479 :class: rtems-table
480
481 * - ``EINVAL``
482   - Invalid argument passed.
483
484**DESCRIPTION:**
485
486This function is used to alter the set of currently blocked signals on a
487process wide basis. A blocked signal will not be received by the process. The
488behavior of this function is dependent on the value of ``how`` which may be one
489of the following:
490
491.. list-table::
492 :class: rtems-table
493
494 * - ``SIG_BLOCK``
495   - The set of blocked signals is set to the union of ``set`` and those
496     signals currently blocked.
497 * - ``SIG_UNBLOCK``
498   - The signals specific in ``set`` are removed from the currently blocked
499     set.
500 * - ``SIG_SETMASK``
501   - The set of currently blocked signals is set to ``set``.
502
503If ``oset`` is not ``NULL``, then the set of blocked signals prior to this call
504is returned in ``oset``. If ``set`` is ``NULL``, no change is done, allowing to
505examine the set of currently blocked signals.
506
507**NOTES:**
508
509It is not an error to unblock a signal which is not blocked.
510
511In the current implementation of RTEMS POSIX API ``sigprocmask()`` is
512technically mapped to ``pthread_sigmask()``.
513
514.. _pthread_sigmask:
515
516pthread_sigmask - Examine and Change Thread Blocked Signals
517-----------------------------------------------------------
518.. index:: pthread_sigmask
519.. index:: examine and change thread blocked signals
520
521**CALLING SEQUENCE:**
522
523.. code-block:: c
524
525    #include <signal.h>
526    int pthread_sigmask(
527    int             how,
528    const sigset_t \*set,
529    sigset_t       \*oset
530    );
531
532**STATUS CODES:**
533
534The function returns 0 on success, otherwise it returns -1 and sets ``errno``
535to indicate the error. ``errno`` may be set to:
536
537*EINVAL*
538    Invalid argument passed.
539
540**DESCRIPTION:**
541
542This function is used to alter the set of currently blocked signals for the
543calling thread. A blocked signal will not be received by the process. The
544behavior of this function is dependent on the value of ``how`` which may be one
545of the following:
546
547.. list-table::
548 :class: rtems-table
549
550 * - ``SIG_BLOCK``
551   - The set of blocked signals is set to the union of ``set`` and those
552     signals currently blocked.
553 * - ``SIG_UNBLOCK``
554   - The signals specific in ``set`` are removed from the currently blocked
555     set.
556 * - ``SIG_SETMASK``
557   - The set of currently blocked signals is set to ``set``.
558
559If ``oset`` is not ``NULL``, then the set of blocked signals prior to this call
560is returned in ``oset``. If ``set`` is ``NULL``, no change is done, allowing to
561examine the set of currently blocked signals.
562
563**NOTES:**
564
565It is not an error to unblock a signal which is not blocked.
566
567.. _kill:
568
569kill - Send a Signal to a Process
570---------------------------------
571.. index:: kill
572.. index:: send a signal to a process
573
574**CALLING SEQUENCE:**
575
576.. code-block:: c
577
578    #include <sys/types.h>
579    #include <signal.h>
580    int kill(
581        pid_t pid,
582        int   sig
583    );
584
585**STATUS CODES:**
586
587The function returns 0 on success, otherwise it returns -1 and sets ``errno`` to
588indicate the error. ``errno`` may be set to:
589
590.. list-table::
591 :class: rtems-table
592
593 * - ``EINVAL``
594   - Invalid argument passed.
595 * - ``EPERM``
596   - Process does not have permission to send the signal to any receiving
597     process.
598 * - ``ESRCH``
599   - The process indicated by the parameter pid is invalid.
600
601**DESCRIPTION:**
602
603This function sends the signal ``sig`` to the process ``pid``.
604
605**NOTES:**
606
607Since RTEMS is a single-process system, a signal can only be sent to the
608calling process (i.e. the current node).
609
610.. _sigpending:
611
612sigpending - Examine Pending Signals
613------------------------------------
614.. index:: sigpending
615.. index:: examine pending signals
616
617**CALLING SEQUENCE:**
618
619.. code-block:: c
620
621    #include <signal.h>
622        int sigpending(
623        const sigset_t *set
624    );
625
626**STATUS CODES:**
627
628The function returns 0 on success, otherwise it returns -1 and sets ``errno``
629to indicate the error. ``errno`` may be set to:
630
631.. list-table::
632 :class: rtems-table
633
634 * - ``EFAULT``
635   - Invalid address for set.
636
637**DESCRIPTION:**
638
639This function allows the caller to examine the set of currently pending
640signals. A pending signal is one which has been raised but is currently
641blocked. The set of pending signals is returned in ``set``.
642
643.. _sigsuspend:
644
645sigsuspend - Wait for a Signal
646------------------------------
647.. index:: sigsuspend
648.. index:: wait for a signal
649
650**CALLING SEQUENCE:**
651
652.. code-block:: c
653
654    #include <signal.h>
655       int sigsuspend(
656       const sigset_t *sigmask
657    );
658
659**STATUS CODES:**
660
661The function returns 0 on success, otherwise it returns -1 and sets ``errno``
662to indicate the error. ``errno`` may be set to:
663
664.. list-table::
665 :class: rtems-table
666
667 * - ``EINTR``
668   - Signal interrupted this function.
669
670**DESCRIPTION:**
671
672This function temporarily replaces the signal mask for the process with that
673specified by ``sigmask`` and blocks the calling thread until a signal is
674raised.
675
676.. _pause:
677
678pause - Suspend Process Execution
679---------------------------------
680.. index:: pause
681.. index:: suspend process execution
682
683**CALLING SEQUENCE:**
684
685.. code-block:: c
686
687    #include <signal.h>
688    int pause( void );
689
690**STATUS CODES:**
691
692The function returns 0 on success, otherwise it returns -1 and sets ``errno``
693to indicate the error. ``errno`` may be set to:
694
695.. list-table::
696 :class: rtems-table
697
698 * - ``EINTR``
699   - Signal interrupted this function.
700
701**DESCRIPTION:**
702
703This function causes the calling thread to be blocked until an unblocked signal
704is received.
705
706.. _sigwait:
707
708sigwait - Synchronously Accept a Signal
709---------------------------------------
710.. index:: sigwait
711.. index:: synchronously accept a signal
712
713**CALLING SEQUENCE:**
714
715.. code-block:: c
716
717    #include <signal.h>
718    int sigwait(
719        const sigset_t *set,
720        int            *sig
721    );
722
723**STATUS CODES:**
724
725The function returns 0 on success, otherwise it returns -1 and sets ``errno``
726to indicate the error. ``errno`` may be set to:
727
728.. list-table::
729 :class: rtems-table
730
731 * - ``EINVAL``
732   - Invalid argument passed.
733 * - ``EINTR``
734   - Signal interrupted this function.
735
736**DESCRIPTION:**
737
738This function selects a pending signal based on the set specified in ``set``,
739atomically clears it from the set of pending signals, and returns the signal
740number for that signal in ``sig``.
741
742.. _sigwaitinfo:
743
744sigwaitinfo - Synchronously Accept a Signal
745-------------------------------------------
746.. index:: sigwaitinfo
747.. index:: synchronously accept a signal
748
749**CALLING SEQUENCE:**
750
751.. code-block:: c
752
753    #include <signal.h>
754    int sigwaitinfo(
755        const sigset_t *set,
756        siginfo_t      *info
757    );
758
759**STATUS CODES:**
760
761The function returns 0 on success, otherwise it returns -1 and sets ``errno``
762to indicate the error. ``errno`` may be set to:
763
764*EINTR*
765    Signal interrupted this function.
766
767**DESCRIPTION:**
768
769This function selects a pending signal based on the set specified in ``set``,
770atomically clears it from the set of pending signals, and returns information
771about that signal in ``info``.
772
773The prototype of the ``siginfo_t`` structure is the following:
774
775.. code-block:: c
776
777    typedef struct
778    {
779        int si_signo;        /* Signal number */
780        int si_code;         /* Cause of the signal */
781        pid_t si_pid;        /* Sending process ID */
782        uid_t si_uid;        /* Real user ID of sending process */
783        void* si_addr;       /* Address of faulting instruction */
784        int si_status;       /* Exit value or signal */
785        union sigval
786        {
787            int sival_int;   /* Integer signal value */
788            void* sival_ptr; /* Pointer signal value */
789        } si_value;          /* Signal value */
790    }
791
792.. _sigtimedwait:
793
794sigtimedwait - Synchronously Accept a Signal with Timeout
795---------------------------------------------------------
796.. index:: sigtimedwait
797.. index:: synchronously accept a signal with timeout
798
799**CALLING SEQUENCE:**
800
801.. code-block:: c
802
803    #include <signal.h>
804    int sigtimedwait(
805        const sigset_t        *set,
806        siginfo_t             *info,
807        const struct timespec *timeout
808    );
809
810**STATUS CODES:**
811
812The function returns 0 on success, otherwise it returns -1 and sets ``errno``
813to indicate the error. ``errno`` may be set to:
814
815.. list-table::
816 :class: rtems-table
817
818 * - ``EAGAIN``
819   - Timed out while waiting for the specified signal set.
820 * - ``EINVAL``
821   - Nanoseconds field of the timeout argument is invalid.
822 * - ``EINTR``
823   - Signal interrupted this function.
824
825**DESCRIPTION:**
826
827This function selects a pending signal based on the set specified in ``set``,
828atomically clears it from the set of pending signals, and returns information
829about that signal in ``info``. The calling thread will block up to ``timeout``
830waiting for the signal to arrive.
831
832The ``timespec`` structure is defined as follows:
833
834.. code-block:: c
835
836    struct timespec
837    {
838        time_t tv_sec; /* Seconds */
839        long tv_nsec;  /* Nanoseconds */
840    }
841
842**NOTES:**
843
844If ``timeout`` is NULL, then the calling thread will wait forever for the
845specified signal set.
846
847.. _sigqueue:
848
849sigqueue - Queue a Signal to a Process
850--------------------------------------
851.. index:: sigqueue
852.. index:: queue a signal to a process
853
854**CALLING SEQUENCE:**
855
856.. code-block:: c
857
858    #include <signal.h>
859    int sigqueue(
860        pid_t              pid,
861        int                signo,
862        const union sigval value
863    );
864
865**STATUS CODES:**
866
867The function returns 0 on success, otherwise it returns -1 and sets ``errno``
868to indicate the error. ``errno`` may be set to:
869
870.. list-table::
871 :class: rtems-table
872
873 * - ``EAGAIN``
874   - No resources available to queue the signal. The process has already queued
875     ``SIGQUEUE_MAX`` signals that are still pending at the receiver or the
876     systemwide resource limit has been exceeded.
877 * - ``EINVAL``
878   - The value of the signo argument is an invalid or unsupported signal
879     number.
880 * - ``EPERM``
881   - The process does not have the appropriate privilege to send the signal to
882     the receiving process.
883 * - ``ESRCH``
884   - The process pid does not exist.
885
886**DESCRIPTION:**
887
888This function sends the signal specified by ``signo`` to the process ``pid``
889
890The ``sigval`` union is specified as:
891
892.. code-block:: c
893
894    union sigval
895    {
896        int sival_int; /* Integer signal value */
897        void* sival_ptr; /* Pointer signal value */
898    }
899
900**NOTES:**
901
902Since RTEMS is a single-process system, a signal can only be sent to the
903calling process (i.e. the current node).
904
905.. _alarm:
906
907alarm - Schedule Alarm
908----------------------
909.. index:: alarm
910.. index:: schedule alarm
911
912**CALLING SEQUENCE:**
913
914.. code-block:: c
915
916    #include <unistd.h>
917    unsigned int alarm(
918        unsigned int seconds
919    );
920
921**STATUS CODES:**
922
923This call always succeeds.
924
925If there was a previous ``alarm()`` request with time remaining, then this
926routine returns the number of seconds until that outstanding alarm would have
927fired. If no previous ``alarm()`` request was outstanding, then zero is
928returned.
929
930**DESCRIPTION:**
931
932The ``alarm()`` service causes the ``SIGALRM`` signal to be generated after the
933number of seconds specified by ``seconds`` has elapsed.
934
935**NOTES:**
936
937Alarm requests do not queue.  If ``alarm`` is called while a previous request
938is outstanding, the call will result in rescheduling the time at which the
939``SIGALRM`` signal will be generated.
940
941If the notification signal, ``SIGALRM``, is not caught or ignored, the calling
942process is terminated.
943
944.. _ualarm:
945
946ualarm - Schedule Alarm in Microseconds
947---------------------------------------
948.. index:: alarm
949.. index:: microseonds alarm
950.. index:: usecs alarm
951.. index:: schedule alarm in microseonds
952
953**CALLING SEQUENCE:**
954
955.. code-block:: c
956
957    #include <unistd.h>
958    useconds_t ualarm(
959        useconds_t useconds,
960        useconds_t interval
961    );
962
963**STATUS CODES:**
964
965This call always succeeds.
966
967If there was a previous ``ualarm()`` request with time remaining, then this
968routine returns the number of seconds until that outstanding alarm would have
969fired. If no previous ``alarm()`` request was outstanding, then zero is
970returned.
971
972**DESCRIPTION:**
973
974The ``ualarm()`` service causes the ``SIGALRM`` signal to be generated after
975the number of microseconds specified by ``useconds`` has elapsed.
976
977When ``interval`` is non-zero, repeated timeout notification occurs with a
978period in microseconds specified by ``interval``.
979
980**NOTES:**
981
982Alarm requests do not queue.  If ``alarm`` is called while a previous request
983is outstanding, the call will result in rescheduling the time at which the
984``SIGALRM`` signal will be generated.
985
986If the notification signal, ``SIGALRM``, is not caught or ignored, the calling
987process is terminated.
Note: See TracBrowser for help on using the repository browser.