1 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
2 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3 | .. COMMENT: All rights reserved. |
---|
4 | |
---|
5 | Signal Manager |
---|
6 | ############## |
---|
7 | |
---|
8 | Introduction |
---|
9 | ============ |
---|
10 | |
---|
11 | The signal manager provides the functionality associated with the generation, |
---|
12 | delivery, and management of process-oriented signals. |
---|
13 | |
---|
14 | The 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 | |
---|
54 | Background |
---|
55 | ========== |
---|
56 | |
---|
57 | Signals |
---|
58 | ------- |
---|
59 | |
---|
60 | POSIX signals are an asynchronous event mechanism. Each process and thread has |
---|
61 | a 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 |
---|
63 | level. Signals which are enabled have a signal handler associated with them. |
---|
64 | When the signal is generated and conditions are met, then the signal handler is |
---|
65 | invoked in the proper process or thread context asynchronous relative to the |
---|
66 | logical thread of execution. |
---|
67 | |
---|
68 | If a signal has been blocked when it is generated, then it is queued and kept |
---|
69 | pending until the thread or process unblocks the signal or explicitly checks |
---|
70 | for it. Traditional, non-real-time POSIX signals do not queue. Thus if a |
---|
71 | process or thread has blocked a particular signal, then multiple occurrences of |
---|
72 | that signal are recorded as a single occurrence of that signal. |
---|
73 | |
---|
74 | .. COMMENT: TODO: SIGRTMIN and SIGRTMAX ? |
---|
75 | |
---|
76 | One can check for the set of outstanding signals that have been blocked. |
---|
77 | Services are provided to check for outstanding process or thread directed |
---|
78 | signals. |
---|
79 | |
---|
80 | Signal Delivery |
---|
81 | --------------- |
---|
82 | |
---|
83 | Signals which are directed at a thread are delivered to the specified thread. |
---|
84 | |
---|
85 | Signals which are directed at a process are delivered to a thread which is |
---|
86 | selected 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 | |
---|
110 | Operations |
---|
111 | ========== |
---|
112 | |
---|
113 | Signal Set Management |
---|
114 | --------------------- |
---|
115 | |
---|
116 | Each process and each thread within that process has a set of individual |
---|
117 | signals and handlers associated with it. Services are provided to construct |
---|
118 | signal sets for the purposes of building signal sets - type ``sigset_t`` - that |
---|
119 | are used to provide arguments to the services that mask, unmask, and check on |
---|
120 | pending signals. |
---|
121 | |
---|
122 | Blocking Until Signal Generation |
---|
123 | -------------------------------- |
---|
124 | |
---|
125 | A thread may block until receipt of a signal. The "sigwait" and "pause" |
---|
126 | families of functions block until the requested signal is received or if using |
---|
127 | ``sigtimedwait()`` until the specified timeout period has elapsed. |
---|
128 | |
---|
129 | Sending a Signal |
---|
130 | ---------------- |
---|
131 | |
---|
132 | This is accomplished via one of a number of services that sends a signal to |
---|
133 | either a process or thread. Signals may be directed at a process by the |
---|
134 | service ``kill()`` or at a thread by the service ``pthread_kill()`` |
---|
135 | |
---|
136 | Directives |
---|
137 | ========== |
---|
138 | |
---|
139 | This section details the signal manager's directives. A subsection is |
---|
140 | dedicated to each of this manager's directives and describes the calling |
---|
141 | sequence, related constants, usage, and status codes. |
---|
142 | |
---|
143 | .. _sigaddset: |
---|
144 | |
---|
145 | sigaddset - 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 | |
---|
162 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
163 | to 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 | |
---|
173 | This function adds the signal ``signo`` to the specified signal ``set``. |
---|
174 | |
---|
175 | **NOTES:** |
---|
176 | |
---|
177 | The set must be initialized using either ``sigemptyset`` or ``sigfillset`` |
---|
178 | before using this function. |
---|
179 | |
---|
180 | .. _sigdelset: |
---|
181 | |
---|
182 | sigdelset - 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 | |
---|
199 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
200 | to 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 | |
---|
210 | This function deletes the signal specified by ``signo`` from the specified |
---|
211 | signal ``set``. |
---|
212 | |
---|
213 | **NOTES:** |
---|
214 | |
---|
215 | The set must be initialized using either ``sigemptyset`` or ``sigfillset`` |
---|
216 | before using this function. |
---|
217 | |
---|
218 | .. _sigfillset: |
---|
219 | |
---|
220 | sigfillset - 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 | |
---|
236 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
237 | to 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 | |
---|
247 | This function fills the specified signal ``set`` such that all signals are set. |
---|
248 | |
---|
249 | .. _sigismember: |
---|
250 | |
---|
251 | sigismember - 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 | |
---|
268 | The function returns either 1 or 0 if completed successfully, otherwise it |
---|
269 | returns -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 | |
---|
279 | This function returns returns 1 if ``signo`` is a member of ``set`` and 0 |
---|
280 | otherwise. |
---|
281 | |
---|
282 | **NOTES:** |
---|
283 | |
---|
284 | The set must be initialized using either ``sigemptyset`` or ``sigfillset`` |
---|
285 | before using this function. |
---|
286 | |
---|
287 | .. _sigemptyset: |
---|
288 | |
---|
289 | sigemptyset - 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 | |
---|
305 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
306 | to 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 | |
---|
316 | This function initializes an empty signal set pointed to by ``set``. |
---|
317 | |
---|
318 | .. _sigaction: |
---|
319 | |
---|
320 | sigaction - 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 | |
---|
338 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
339 | to 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 | |
---|
351 | If the argument act is not a null pointer, it points to a structure specifying |
---|
352 | the action to be associated with the specified signal. If the argument oact is |
---|
353 | not a null pointer, the action previously associated with the signal is stored |
---|
354 | in the location pointed to by the argument oact. If the argument act is a null |
---|
355 | pointer, signal handling is unchanged; thus, the call can be used to enquire |
---|
356 | about the current handling of a given signal. |
---|
357 | |
---|
358 | The 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 |
---|
375 | their storage may overlap. |
---|
376 | |
---|
377 | If the ``SA_SIGINFO`` flag (see below) is set in ``sa_flags``, the |
---|
378 | ``sa_sigaction`` field specifies a signal-catching function, |
---|
379 | otherwise``sa_handler`` specifies the action to be associated with the signal, |
---|
380 | which may be a signal-catching function or one of the macros ``SIG_IGN`` or |
---|
381 | ``SIG_DFN``. |
---|
382 | |
---|
383 | The 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 | |
---|
395 | The 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 | |
---|
416 | The signal number cannot be SIGKILL. |
---|
417 | |
---|
418 | .. _pthread_kill: |
---|
419 | |
---|
420 | pthread_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 | |
---|
437 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` to |
---|
438 | indicate 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 | |
---|
450 | This functions sends the specified signal ``sig`` to a thread referenced to by |
---|
451 | ``thread``. |
---|
452 | |
---|
453 | If the signal code is ``0``, arguments are validated and no signal is sent. |
---|
454 | |
---|
455 | .. _sigprocmask: |
---|
456 | |
---|
457 | sigprocmask - 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 | |
---|
475 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
476 | to 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 | |
---|
486 | This function is used to alter the set of currently blocked signals on a |
---|
487 | process wide basis. A blocked signal will not be received by the process. The |
---|
488 | behavior of this function is dependent on the value of ``how`` which may be one |
---|
489 | of 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 | |
---|
503 | If ``oset`` is not ``NULL``, then the set of blocked signals prior to this call |
---|
504 | is returned in ``oset``. If ``set`` is ``NULL``, no change is done, allowing to |
---|
505 | examine the set of currently blocked signals. |
---|
506 | |
---|
507 | **NOTES:** |
---|
508 | |
---|
509 | It is not an error to unblock a signal which is not blocked. |
---|
510 | |
---|
511 | In the current implementation of RTEMS POSIX API ``sigprocmask()`` is |
---|
512 | technically mapped to ``pthread_sigmask()``. |
---|
513 | |
---|
514 | .. _pthread_sigmask: |
---|
515 | |
---|
516 | pthread_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 | |
---|
534 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
535 | to indicate the error. ``errno`` may be set to: |
---|
536 | |
---|
537 | *EINVAL* |
---|
538 | Invalid argument passed. |
---|
539 | |
---|
540 | **DESCRIPTION:** |
---|
541 | |
---|
542 | This function is used to alter the set of currently blocked signals for the |
---|
543 | calling thread. A blocked signal will not be received by the process. The |
---|
544 | behavior of this function is dependent on the value of ``how`` which may be one |
---|
545 | of 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 | |
---|
559 | If ``oset`` is not ``NULL``, then the set of blocked signals prior to this call |
---|
560 | is returned in ``oset``. If ``set`` is ``NULL``, no change is done, allowing to |
---|
561 | examine the set of currently blocked signals. |
---|
562 | |
---|
563 | **NOTES:** |
---|
564 | |
---|
565 | It is not an error to unblock a signal which is not blocked. |
---|
566 | |
---|
567 | .. _kill: |
---|
568 | |
---|
569 | kill - 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 | |
---|
587 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` to |
---|
588 | indicate 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 | |
---|
603 | This function sends the signal ``sig`` to the process ``pid``. |
---|
604 | |
---|
605 | **NOTES:** |
---|
606 | |
---|
607 | Since RTEMS is a single-process system, a signal can only be sent to the |
---|
608 | calling process (i.e. the current node). |
---|
609 | |
---|
610 | .. _sigpending: |
---|
611 | |
---|
612 | sigpending - 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 | |
---|
628 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
629 | to 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 | |
---|
639 | This function allows the caller to examine the set of currently pending |
---|
640 | signals. A pending signal is one which has been raised but is currently |
---|
641 | blocked. The set of pending signals is returned in ``set``. |
---|
642 | |
---|
643 | .. _sigsuspend: |
---|
644 | |
---|
645 | sigsuspend - 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 | |
---|
661 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
662 | to 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 | |
---|
672 | This function temporarily replaces the signal mask for the process with that |
---|
673 | specified by ``sigmask`` and blocks the calling thread until a signal is |
---|
674 | raised. |
---|
675 | |
---|
676 | .. _pause: |
---|
677 | |
---|
678 | pause - 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 | |
---|
692 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
693 | to 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 | |
---|
703 | This function causes the calling thread to be blocked until an unblocked signal |
---|
704 | is received. |
---|
705 | |
---|
706 | .. _sigwait: |
---|
707 | |
---|
708 | sigwait - 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 | |
---|
725 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
726 | to 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 | |
---|
738 | This function selects a pending signal based on the set specified in ``set``, |
---|
739 | atomically clears it from the set of pending signals, and returns the signal |
---|
740 | number for that signal in ``sig``. |
---|
741 | |
---|
742 | .. _sigwaitinfo: |
---|
743 | |
---|
744 | sigwaitinfo - 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 | |
---|
761 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
762 | to indicate the error. ``errno`` may be set to: |
---|
763 | |
---|
764 | *EINTR* |
---|
765 | Signal interrupted this function. |
---|
766 | |
---|
767 | **DESCRIPTION:** |
---|
768 | |
---|
769 | This function selects a pending signal based on the set specified in ``set``, |
---|
770 | atomically clears it from the set of pending signals, and returns information |
---|
771 | about that signal in ``info``. |
---|
772 | |
---|
773 | The 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 | |
---|
794 | sigtimedwait - 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 | |
---|
812 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
813 | to 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 | |
---|
827 | This function selects a pending signal based on the set specified in ``set``, |
---|
828 | atomically clears it from the set of pending signals, and returns information |
---|
829 | about that signal in ``info``. The calling thread will block up to ``timeout`` |
---|
830 | waiting for the signal to arrive. |
---|
831 | |
---|
832 | The ``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 | |
---|
844 | If ``timeout`` is NULL, then the calling thread will wait forever for the |
---|
845 | specified signal set. |
---|
846 | |
---|
847 | .. _sigqueue: |
---|
848 | |
---|
849 | sigqueue - 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 | |
---|
867 | The function returns 0 on success, otherwise it returns -1 and sets ``errno`` |
---|
868 | to 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 | |
---|
888 | This function sends the signal specified by ``signo`` to the process ``pid`` |
---|
889 | |
---|
890 | The ``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 | |
---|
902 | Since RTEMS is a single-process system, a signal can only be sent to the |
---|
903 | calling process (i.e. the current node). |
---|
904 | |
---|
905 | .. _alarm: |
---|
906 | |
---|
907 | alarm - 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 | |
---|
923 | This call always succeeds. |
---|
924 | |
---|
925 | If there was a previous ``alarm()`` request with time remaining, then this |
---|
926 | routine returns the number of seconds until that outstanding alarm would have |
---|
927 | fired. If no previous ``alarm()`` request was outstanding, then zero is |
---|
928 | returned. |
---|
929 | |
---|
930 | **DESCRIPTION:** |
---|
931 | |
---|
932 | The ``alarm()`` service causes the ``SIGALRM`` signal to be generated after the |
---|
933 | number of seconds specified by ``seconds`` has elapsed. |
---|
934 | |
---|
935 | **NOTES:** |
---|
936 | |
---|
937 | Alarm requests do not queue. If ``alarm`` is called while a previous request |
---|
938 | is outstanding, the call will result in rescheduling the time at which the |
---|
939 | ``SIGALRM`` signal will be generated. |
---|
940 | |
---|
941 | If the notification signal, ``SIGALRM``, is not caught or ignored, the calling |
---|
942 | process is terminated. |
---|
943 | |
---|
944 | .. _ualarm: |
---|
945 | |
---|
946 | ualarm - 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 | |
---|
965 | This call always succeeds. |
---|
966 | |
---|
967 | If there was a previous ``ualarm()`` request with time remaining, then this |
---|
968 | routine returns the number of seconds until that outstanding alarm would have |
---|
969 | fired. If no previous ``alarm()`` request was outstanding, then zero is |
---|
970 | returned. |
---|
971 | |
---|
972 | **DESCRIPTION:** |
---|
973 | |
---|
974 | The ``ualarm()`` service causes the ``SIGALRM`` signal to be generated after |
---|
975 | the number of microseconds specified by ``useconds`` has elapsed. |
---|
976 | |
---|
977 | When ``interval`` is non-zero, repeated timeout notification occurs with a |
---|
978 | period in microseconds specified by ``interval``. |
---|
979 | |
---|
980 | **NOTES:** |
---|
981 | |
---|
982 | Alarm requests do not queue. If ``alarm`` is called while a previous request |
---|
983 | is outstanding, the call will result in rescheduling the time at which the |
---|
984 | ``SIGALRM`` signal will be generated. |
---|
985 | |
---|
986 | If the notification signal, ``SIGALRM``, is not caught or ignored, the calling |
---|
987 | process is terminated. |
---|