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