source: rtems/doc/new_chapters/signal.t @ 68c46026

4.104.114.84.95
Last change on this file since 68c46026 was 68c46026, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/98 at 21:26:39

Added message to "return -1 and set errno".

  • Property mode set to 100644
File size: 13.7 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-1998.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter Signal Manager
10
11@section Introduction
12
13The signal manager ...
14
15The directives provided by the signal manager are:
16
17@itemize @bullet
18@item @code{sigaddset} - Add a Signal to a Signal Set
19@item @code{sigdelset} - Delete a Signal from a Signal Set
20@item @code{sigfillset} - Fill a Signal Set
21@item @code{sigismember} - Is Signal a Member of a Signal Set
22@item @code{sigemptyset} - Empty a Signal Set
23@item @code{sigaction} - Examine and Change Signal Action
24@item @code{pthread_kill} - Send a Signal to a Thread
25@item @code{sigprocmask} - Examine and Change Process Blocked Signals
26@item @code{pthread_sigmask} - Examine and Change Thread Blocked Signals
27@item @code{kill} - Send a Signal to a Process
28@item @code{sigpending} - Examine Pending Signals
29@item @code{sigsuspend} - Wait for a Signal
30@item @code{pause} - Suspend Process Execution
31@item @code{sigwait} - Synchronously Accept a Signal
32@item @code{sigwaitinfo} - Synchronously Accept a Signal
33@item @code{sigtimedwait} - Synchronously Accept a Signal with Timeout
34@item @code{sigqueue} - Queue a Signal to a Process
35@item @code{alarm} - Schedule Alarm
36@end itemize
37
38@section Background
39
40@subsection Signal Delivery
41
42Signals directed at a thread are delivered to the specified thread.
43
44Signals directed at a process are delivered to a thread which is selected
45based on the following algorithm:
46
47@enumerate
48@item If the action for this signal is currently @code{SIG_IGN},
49then the signal is simply ignored.
50
51@item If the currently executing thread has the signal unblocked, then
52the signal is delivered to it.
53
54@item If any threads are currently blocked waiting for this signal
55(@code{sigwait()}), then the signal is delivered to the highest priority
56thread waiting for this signal.
57
58@item If any other threads are willing to accept delivery of the signal, then
59the signal is delivered to the highest priority thread of this set.  In the
60event, multiple threads of the same priority are willing to accept this
61signal, then priority is given first to ready threads, then to threads
62blocked on calls which may be interrupted, and finally to threads blocked
63on non-interruptible calls.
64
65@item In the event the signal still can not be delivered, then it is left
66pending.  The first thread to unblock the signal (@code{sigprocmask()} or
67@code{pthread_sigprocmask()}) or to wait for this signal
68(@code{sigwait()}) will be the recipient of the signal.
69
70@end enumerate
71
72@section Operations
73
74There is currently no text in this section.
75
76@section Directives
77
78This section details the signal manager's directives.
79A subsection is dedicated to each of this manager's directives
80and describes the calling sequence, related constants, usage,
81and status codes.
82
83@page
84@subsection sigaddset - Add a Signal to a Signal Set
85
86@subheading CALLING SEQUENCE:
87
88@example
89#include <signal.h>
90
91int sigaddset(
92  sigset_t   *set,
93  int         signo
94);
95@end example
96
97@subheading STATUS CODES:
98
99@table @b
100@item EINVAL
101Invalid argument passed.
102
103@end table
104
105@subheading DESCRIPTION:
106
107This function adds the @code{signo} to the specified signal @code{set}.
108
109@subheading NOTES:
110
111@page
112@subsection sigdelset - Delete a Signal from a Signal Set
113
114@subheading CALLING SEQUENCE:
115
116@example
117#include <signal.h>
118
119int sigdelset(
120  sigset_t   *set,
121  int         signo
122);
123@end example
124
125@subheading STATUS CODES:
126
127@table @b
128@item EINVAL
129Invalid argument passed.
130
131@end table
132
133@subheading DESCRIPTION:
134
135This function deletes the @code{signo} to the specified signal @code{set}.
136
137@subheading NOTES:
138
139NONE
140
141@page
142@subsection sigfillset - Fill a Signal Set
143
144@subheading CALLING SEQUENCE:
145
146@example
147#include <signal.h>
148
149int sigfillset(
150  sigset_t   *set
151);
152@end example
153
154@subheading STATUS CODES:
155
156@table @b
157
158@item EINVAL
159Invalid argument passed.
160
161@end table
162
163@subheading DESCRIPTION:
164
165This function fills the specified signal @code{set} such that all
166signals are set.
167
168@subheading NOTES:
169
170NONE
171
172@page
173@subsection sigismember - Is Signal a Member of a Signal Set
174
175@subheading CALLING SEQUENCE:
176
177@example
178#include <signal.h>
179
180int sigismember(
181  const sigset_t   *set,
182  int               signo
183);
184@end example
185
186@subheading STATUS CODES:
187
188@table @b
189
190@item EINVAL
191Invalid argument passed.
192
193@end table
194
195@subheading DESCRIPTION:
196
197This function returns returns 1 if @code{signo} is a member of @code{set}
198and 0 otherwise.
199
200@subheading NOTES:
201
202NONE
203
204@page
205@subsection sigemptyset - Empty a Signal Set
206
207@subheading CALLING SEQUENCE:
208
209@example
210#include <signal.h>
211
212int sigemptyset(
213  sigset_t   *set
214);
215@end example
216
217@subheading STATUS CODES:
218
219@table @b
220
221@item EINVAL
222Invalid argument passed.
223
224@end table
225
226@subheading DESCRIPTION:
227
228This function fills the specified signal @code{set} such that all
229signals are cleared.
230
231@subheading NOTES:
232
233NONE
234
235@page
236@subsection sigaction - Examine and Change Signal Action
237
238@subheading CALLING SEQUENCE:
239
240@example
241#include <signal.h>
242
243int sigaction(
244  int                     sig,
245  const struct sigaction *act,
246  struct sigaction       *oact
247);
248@end example
249
250@subheading STATUS CODES:
251
252@table @b
253@item EINVAL
254Invalid argument passed.
255
256@item ENOTSUP
257Realtime Signals Extension option not supported.
258
259@end table
260
261@subheading DESCRIPTION:
262
263This function is used to change the action taken by a process on
264receipt of the specfic signal @code{sig}.  The new action is
265specified by @code{act} and the previous action is returned
266via @code{oact}.
267
268@subheading NOTES:
269
270The signal number cannot be SIGKILL.
271
272@page
273@subsection pthread_kill - Send a Signal to a Thread
274
275@subheading CALLING SEQUENCE:
276
277@example
278#include <signal.h>
279
280int pthread_kill(
281  pthread_t   thread,
282  int         sig
283);
284@end example
285
286@subheading STATUS CODES:
287
288@table @b
289
290@item ESRCH
291The thread indicated by the parameter thread is invalid.
292
293@item EINVAL
294Invalid argument passed.
295
296@end table
297
298@subheading DESCRIPTION:
299
300This functions sends the specified signal @code{sig} to @code{thread}.
301
302@subheading NOTES:
303
304NONE
305
306@page
307@subsection sigprocmask - Examine and Change Process Blocked Signals
308 
309@subheading CALLING SEQUENCE:
310 
311@example
312#include <signal.h>
313 
314int sigprocmask(
315  int               how,
316  const sigset_t   *set,
317  sigset_t         *oset
318);
319@end example
320 
321@subheading STATUS CODES:
322
323@table @b
324
325@item EINVAL
326Invalid argument passed.
327 
328@end table
329 
330@subheading DESCRIPTION:
331 
332This function is used to alter the set of currently blocked signals
333on a process wide basis.  A blocked signal will not be received by the
334process.  The behavior of this function is dependent on the value of
335@code{how} which may be one of the following:
336
337@table @code
338
339@item SIG_BLOCK
340The set of blocked signals is set to the union of @code{set} and
341those signals currently blocked.
342
343@item SIG_UNBLOCK
344The signals specific in @code{set} are removed from the currently
345blocked set.
346
347@item SIG_SETMASK
348The set of currently blocked signals is set to @code{set}.
349
350@end table
351
352If @code{oset} is not @code{NULL}, then the set of blocked signals
353prior to this call is returned in @code{oset}.
354
355@subheading NOTES:
356
357It is not an error to unblock a signal which is not blocked.
358
359@page
360@subsection pthread_sigmask - Examine and Change Thread Blocked Signals
361
362@subheading CALLING SEQUENCE:
363
364@example
365#include <signal.h>
366
367int pthread_sigmask(
368  int               how,
369  const sigset_t   *set,
370  sigset_t         *oset
371);
372@end example
373
374@subheading STATUS CODES:
375@table @b
376@item EINVAL
377Invalid argument passed.
378
379@end table
380
381@subheading DESCRIPTION:
382
383This function is used to alter the set of currently blocked signals
384for the calling thread.  A blocked signal will not be received by the
385process.  The behavior of this function is dependent on the value of
386@code{how} which may be one of the following:
387
388@table @code
389@item SIG_BLOCK
390The set of blocked signals is set to the union of @code{set} and
391those signals currently blocked.
392
393@item SIG_UNBLOCK
394The signals specific in @code{set} are removed from the currently
395blocked set.
396
397@item SIG_SETMASK
398The set of currently blocked signals is set to @code{set}.
399
400@end table
401
402If @code{oset} is not @code{NULL}, then the set of blocked signals
403prior to this call is returned in @code{oset}.
404
405@subheading NOTES:
406
407It is not an error to unblock a signal which is not blocked.
408
409
410@page
411@subsection kill - Send a Signal to a Process
412
413@subheading CALLING SEQUENCE:
414
415@example
416#include <sys/types.h>
417#include <signal.h>
418
419int kill(
420  pid_t pid,
421  int   sig
422);
423@end example
424
425@subheading STATUS CODES:
426@table @b
427@item EINVAL
428Invalid argument passed.
429
430@item EPERM
431Process does not have permission to send the signal to any receiving process.
432
433@item ESRCH
434The process indicated by the parameter pid is invalid.
435
436@end table
437
438@subheading DESCRIPTION:
439
440This function sends the signal @code{sig} to the process @code{pid}.
441
442@subheading NOTES:
443
444NONE
445 
446@page
447@subsection sigpending - Examine Pending Signals
448 
449@subheading CALLING SEQUENCE:
450 
451@example
452#include <signal.h>
453 
454int sigpending(
455  const sigset_t  *set
456);
457@end example
458 
459@subheading STATUS CODES:
460
461On error, this routine returns -1 and sets @code{errno} to one of
462the following:
463 
464@table @b
465
466@item EFAULT
467Invalid address for set.
468
469@end table
470
471@subheading DESCRIPTION:
472
473This function allows the caller to examine the set of currently pending
474signals.  A pending signal is one which has been raised but is currently
475blocked.  The set of pending signals is returned in @code{set}.
476 
477@subheading NOTES:
478
479NONE
480
481@page
482@subsection sigsuspend - Wait for a Signal
483 
484@subheading CALLING SEQUENCE:
485 
486@example
487#include <signal.h>
488 
489int sigsuspend(
490  const sigset_t  *sigmask
491);
492@end example
493 
494@subheading STATUS CODES:
495
496On error, this routine returns -1 and sets @code{errno} to one of
497the following:
498
499@table @b
500
501@item EINTR
502Signal interrupted this function.
503 
504@end table
505 
506@subheading DESCRIPTION:
507
508This function temporarily replaces the signal mask for the process
509with that specified by @code{sigmask} and blocks the calling thread
510until the signal is raised.
511 
512@subheading NOTES:
513
514NONE
515
516@page
517@subsection pause - Suspend Process Execution
518 
519@subheading CALLING SEQUENCE:
520 
521@example
522#include <signal.h>
523 
524int pause( void );
525@end example
526 
527@subheading STATUS CODES:
528
529On error, this routine returns -1 and sets @code{errno} to one of
530the following:
531
532@table @b
533 
534@item EINTR
535Signal interrupted this function.
536 
537@end table
538 
539@subheading DESCRIPTION:
540
541This function causes the calling thread to be blocked until the signal
542is received.
543 
544@subheading NOTES:
545
546NONE
547 
548@page
549@subsection sigwait - Synchronously Accept a Signal
550
551@subheading CALLING SEQUENCE:
552
553@example
554#include <signal.h>
555
556int sigwait(
557  const sigset_t  *set,
558  int             *sig
559);
560@end example
561
562@subheading STATUS CODES:
563@table @b
564@item EINVAL
565Invalid argument passed.
566
567@item EINTR
568Signal interrupted this function.
569
570@end table
571
572@subheading DESCRIPTION:
573
574This function selects a pending signal based on the set specified in
575@code{set}, atomically clears it from the set of pending signals, and
576returns the signal number for that signal in @code{sig}.
577
578
579@subheading NOTES:
580
581NONE
582
583@page
584@subsection sigwaitinfo - Synchronously Accept a Signal
585 
586@subheading CALLING SEQUENCE:
587 
588@example
589#include <signal.h>
590 
591int sigwaitinfo(
592  const sigset_t  *set,
593  siginfo_t       *info
594);
595@end example
596 
597@subheading STATUS CODES:
598@table @b
599@item EINTR
600Signal interrupted this function.
601 
602@end table
603 
604@subheading DESCRIPTION:
605 
606This function selects a pending signal based on the set specified in
607@code{set}, atomically clears it from the set of pending signals, and
608returns information about that signal in @code{info}.
609
610@subheading NOTES:
611
612NONE
613
614@page
615@subsection sigtimedwait - Synchronously Accept a Signal with Timeout
616 
617@subheading CALLING SEQUENCE:
618 
619@example
620#include <signal.h>
621 
622int sigtimedwait(
623  const sigset_t         *set,
624  siginfo_t              *info,
625  const struct timespec  *timeout
626);
627@end example
628 
629@subheading STATUS CODES:
630@table @b
631@item EAGAIN
632Timed out while waiting for the specified signal set.
633 
634@item EINVAL
635Nanoseconds field of the timeout argument is invalid.
636 
637@item EINTR
638Signal interrupted this function.
639 
640@end table
641 
642@subheading DESCRIPTION:
643 
644This function selects a pending signal based on the set specified in
645@code{set}, atomically clears it from the set of pending signals, and
646returns information about that signal in @code{info}.  The calling thread
647will block up to @code{timeout} waiting for the signal to arrive.
648
649@subheading NOTES:
650
651If @code{timeout} is NULL, then the calling thread will wait forever for
652the specified signal set.
653
654@page
655@subsection sigqueue - Queue a Signal to a Process
656 
657@subheading CALLING SEQUENCE:
658 
659@example
660#include <signal.h>
661 
662int sigqueue(
663  pid_t               pid,
664  int                 signo,
665  const union sigval  value
666);
667@end example
668 
669@subheading STATUS CODES:
670
671@table @b
672
673@item EAGAIN
674No resources available to queue the signal.  The process has already
675queued SIGQUEUE_MAX signals that are still pending at the receiver
676or the systemwide resource limit has been exceeded.
677 
678@item EINVAL
679The value of the signo argument is an invalid or unsupported signal
680number.
681 
682@item EPERM
683The process does not have the appropriate privilege to send the signal
684to the receiving process.
685
686@item ESRCH
687The process pid does not exist.
688 
689@end table
690 
691@subheading DESCRIPTION:
692
693This function sends the signal specified by @code{signo} to the
694process @code{pid}
695 
696@subheading NOTES:
697
698NONE
699
700@page
701@subsection alarm - Schedule Alarm
702 
703@subheading CALLING SEQUENCE:
704 
705@example
706#include <signal.h>
707 
708unsigned int alarm(
709  unsigned int  seconds
710);
711@end example
712 
713@subheading STATUS CODES:
714
715This call always succeeds.
716 
717@subheading DESCRIPTION:
718 
719If there was a previous @code{alarm()} request with time remaining,
720then this routine returns the number of seconds until that outstanding
721alarm would have fired.  If no previous @code{alarm()} request was
722outstanding, then zero is returned.
723
724@subheading NOTES:
725
726NONE
Note: See TracBrowser for help on using the repository browser.