source: rtems-docs/posix_users/signal.rst @ 9aafb39

4.115
Last change on this file since 9aafb39 was 36def91, checked in by Joel Sherrill <joel@…>, on 10/28/16 at 00:47:07

rtems-docs: Fix many unnecessary back slashes

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