1 .\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"*******************************************************************
26 .\" This file was generated with po4a. Translate the source file.
28 .\"*******************************************************************
29 .TH PTHREAD_SIGMASK 3 2011\-10\-16 Linux "Linux Programmer's Manual"
31 pthread_sigmask \- 禁止するシグナルマスクの確認と変更を行う
34 \fB#include <signal.h>\fP
36 \fBint pthread_sigmask(int \fP\fIhow\fP\fB, const sigset_t *\fP\fIset\fP\fB, sigset_t *\fP\fIoldset\fP\fB);\fP
39 \fI\-pthread\fP を付けてコンパイルとリンクを行う。
41 \fBpthread_sigmask\fP() 関数は \fBsigprocmask\fP(2) と全く同様だが、
42 マルチスレッドプログラムでの利用が POSIX.1\-2001 で明示的に規定されて
43 いる点が異なる。他の違いはこのマニュアルページで説明する。
45 この関数の引き数と動作の説明は \fBsigprocmask\fP(2) を参照。
47 成功すると、 \fBpthread_sigmask\fP() は 0 を返す。
50 \fBsigprocmask\fP(2) を参照。
54 新しいスレッドは、スレッドを作成したスレッドのシグナルマスクのコピーを
57 以下のプログラムは、メインスレッドでシグナルのいくつかを禁止 (block)
58 するように設定を行い、 \fBsigwait\fP(3) 経由でそれらのシグナルを集める
60 下記のシェルのセッションはその利用例を示したものである。
66 $\fB kill \-QUIT %1\fP
67 Signal handling thread got signal 3
68 $\fB kill \-USR1 %1\fP
69 Signal handling thread got signal 10
70 $\fB kill \-TERM %1\fP
71 [1]+ Terminated ./a.out
84 /* Simple error handling functions */
86 #define handle_error_en(en, msg) \e
87 do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
92 sigset_t *set = (sigset_t *) arg;
96 s = sigwait(set, &sig);
98 handle_error_en(s, "sigwait");
99 printf("Signal handling thread got signal %d\en", sig);
104 main(int argc, char *argv[])
110 /* Block SIGQUIT and SIGUSR1; other threads created by main()
111 will inherit a copy of the signal mask. */
114 sigaddset(&set, SIGQUIT);
115 sigaddset(&set, SIGUSR1);
116 s = pthread_sigmask(SIG_BLOCK, &set, NULL);
118 handle_error_en(s, "pthread_sigmask");
120 s = pthread_create(&thread, NULL, &sig_thread, (void *) &set);
122 handle_error_en(s, "pthread_create");
124 /* Main thread carries on to create other threads and/or do
127 pause(); /* Dummy pause so we can test program */
131 \fBsigaction\fP(2), \fBsigpending\fP(2), \fBsigprocmask\fP(2) \fBpthread_create\fP(3),
132 \fBpthread_kill\fP(3), \fBsigsetops\fP(3), \fBpthreads\fP(7), \fBsignal\fP(7)
134 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
135 である。プロジェクトの説明とバグ報告に関する情報は
136 http://www.kernel.org/doc/man\-pages/ に書かれている。