1 .\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"*******************************************************************
28 .\" This file was generated with po4a. Translate the source file.
30 .\"*******************************************************************
31 .TH PTHREAD_SIGMASK 3 2012\-08\-03 Linux "Linux Programmer's Manual"
33 pthread_sigmask \- 禁止するシグナルマスクの確認と変更を行う
36 \fB#include <signal.h>\fP
38 \fBint pthread_sigmask(int \fP\fIhow\fP\fB, const sigset_t *\fP\fIset\fP\fB, sigset_t *\fP\fIoldset\fP\fB);\fP
41 \fI\-pthread\fP を付けてコンパイルとリンクを行う。
43 \fBpthread_sigmask\fP() 関数は \fBsigprocmask\fP(2) と全く同様だが、
44 マルチスレッドプログラムでの利用が POSIX.1\-2001 で明示的に規定されて
45 いる点が異なる。他の違いはこのマニュアルページで説明する。
47 この関数の引き数と動作の説明は \fBsigprocmask\fP(2) を参照。
49 成功すると、 \fBpthread_sigmask\fP() は 0 を返す。
52 \fBsigprocmask\fP(2) を参照。
56 新しいスレッドは、スレッドを作成したスレッドのシグナルマスクのコピーを
59 以下のプログラムは、メインスレッドでシグナルのいくつかを禁止 (block)
60 するように設定を行い、 \fBsigwait\fP(3) 経由でそれらのシグナルを集める
62 下記のシェルのセッションはその利用例を示したものである。
68 $\fB kill \-QUIT %1\fP
69 Signal handling thread got signal 3
70 $\fB kill \-USR1 %1\fP
71 Signal handling thread got signal 10
72 $\fB kill \-TERM %1\fP
73 [1]+ Terminated ./a.out
86 /* Simple error handling functions */
88 #define handle_error_en(en, msg) \e
89 do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
98 s = sigwait(set, &sig);
100 handle_error_en(s, "sigwait");
101 printf("Signal handling thread got signal %d\en", sig);
106 main(int argc, char *argv[])
112 /* Block SIGQUIT and SIGUSR1; other threads created by main()
113 will inherit a copy of the signal mask. */
116 sigaddset(&set, SIGQUIT);
117 sigaddset(&set, SIGUSR1);
118 s = pthread_sigmask(SIG_BLOCK, &set, NULL);
120 handle_error_en(s, "pthread_sigmask");
122 s = pthread_create(&thread, NULL, &sig_thread, (void *) &set);
124 handle_error_en(s, "pthread_create");
126 /* Main thread carries on to create other threads and/or do
129 pause(); /* Dummy pause so we can test program */
133 \fBsigaction\fP(2), \fBsigpending\fP(2), \fBsigprocmask\fP(2), \fBpthread_create\fP(3),
134 \fBpthread_kill\fP(3), \fBsigsetops\fP(3), \fBpthreads\fP(7), \fBsignal\fP(7)
136 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
137 である。プロジェクトの説明とバグ報告に関する情報は
138 http://www.kernel.org/doc/man\-pages/ に書かれている。