OSDN Git Service

d6e02336c32f88b06162b4c7748e1c8d063c2a92
[linuxjm/LDP_man-pages.git] / original / man2 / sigprocmask.2
1 .\" Copyright (c) 2005 Michael Kerrisk
2 .\" based on earlier work by faith@cs.unc.edu and
3 .\" Mike Battersby <mib@deakin.edu.au>
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2
26 .\"
27 .TH SIGPROCMASK 2 2008-10-17 "Linux" "Linux Programmer's Manual"
28 .SH NAME
29 sigprocmask \- examine and change blocked signals
30 .SH SYNOPSIS
31 .B #include <signal.h>
32 .sp
33 .BI "int sigprocmask(int " how ", const sigset_t *" set ,
34 .BI "sigset_t *" oldset );
35 .sp
36 .in -4n
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .in
40 .sp
41 .ad l
42 .BR sigprocmask ():
43 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
44 .ad b
45 .SH DESCRIPTION
46 .BR sigprocmask ()
47 is used to fetch and/or change the signal mask of the calling thread.
48 The signal mask is the set of signals whose delivery is currently
49 blocked for the caller
50 (see also
51 .BR signal (7)
52 for more details).
53
54 The behavior of the call is dependent on the value of
55 .IR how ,
56 as follows.
57 .TP
58 .B SIG_BLOCK
59 The set of blocked signals is the union of the current set and the
60 .I set
61 argument.
62 .TP
63 .B SIG_UNBLOCK
64 The signals in
65 .I set
66 are removed from the current set of blocked signals.
67 It is permissible to attempt to unblock a signal which is not blocked.
68 .TP
69 .B SIG_SETMASK
70 The set of blocked signals is set to the argument
71 .IR set .
72 .PP
73 If
74 .I oldset
75 is non-NULL, the previous value of the signal mask is stored in
76 .IR oldset .
77
78 If
79 .I set
80 is NULL, then the signal mask is unchanged (i.e.,
81 .I how
82 is ignored),
83 but the current value of the signal mask is nevertheless returned in
84 .I oldset
85 (if it is not NULL).
86
87 The use of
88 .BR sigprocmask ()
89 is unspecified in a multithreaded process; see
90 .BR pthread_sigmask (3).
91 .SH "RETURN VALUE"
92 .BR sigprocmask ()
93 returns 0 on success and \-1 on error.
94 .SH ERRORS
95 .B EINVAL
96 The value specified in
97 .I how
98 was invalid.
99 .SH "CONFORMING TO"
100 POSIX.1-2001.
101 .SH NOTES
102 It is not possible to block
103 .BR SIGKILL " or " SIGSTOP .
104 Attempts to do so are silently ignored.
105
106 Each of the threads in a process has its own signal mask.
107
108 A child created via
109 .BR fork (2)
110 inherits a copy of its parent's signal mask;
111 the signal mask is preserved across
112 .BR execve (2).
113
114 If
115 .BR SIGBUS ,
116 .BR SIGFPE ,
117 .BR SIGILL ,
118 or
119 .B SIGSEGV
120 are generated
121 while they are blocked, the result is undefined,
122 unless the signal was generated by
123 .BR kill (2),
124 .BR sigqueue (2),
125 or
126 .BR raise (3).
127 .PP
128 See
129 .BR sigsetops (3)
130 for details on manipulating signal sets.
131 .SH "SEE ALSO"
132 .BR kill (2),
133 .BR pause (2),
134 .BR sigaction (2),
135 .BR signal (2),
136 .BR sigpending (2),
137 .BR sigqueue (2),
138 .BR sigsuspend (2),
139 .BR pthread_sigmask (3),
140 .BR sigsetops (3),
141 .BR signal (7)