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 .\"*******************************************************************
32 .\" Japanese Version Copyright (c) 2012 Akihiro MOTOKI
33 .\" all rights reserved.
34 .\" Translated 2012-05-04, Akihiro MOTOKI <amotoki@gmail.com>
36 .TH PTHREAD_SIGMASK 3 2012\-08\-03 Linux "Linux Programmer's Manual"
38 pthread_sigmask \- 禁止するシグナルマスクの確認と変更を行う
41 \fB#include <signal.h>\fP
43 \fBint pthread_sigmask(int \fP\fIhow\fP\fB, const sigset_t *\fP\fIset\fP\fB, sigset_t *\fP\fIoldset\fP\fB);\fP
46 \fI\-pthread\fP を付けてコンパイルとリンクを行う。
48 \fBpthread_sigmask\fP() 関数は \fBsigprocmask\fP(2) と全く同様だが、
49 マルチスレッドプログラムでの利用が POSIX.1\-2001 で明示的に規定されて
50 いる点が異なる。他の違いはこのマニュアルページで説明する。
52 この関数の引き数と動作の説明は \fBsigprocmask\fP(2) を参照。
54 成功すると、 \fBpthread_sigmask\fP() は 0 を返す。
57 \fBsigprocmask\fP(2) を参照。
61 新しいスレッドは、スレッドを作成したスレッドのシグナルマスクのコピーを
64 以下のプログラムは、メインスレッドでシグナルのいくつかを禁止 (block)
65 するように設定を行い、 \fBsigwait\fP(3) 経由でそれらのシグナルを集める
67 下記のシェルのセッションはその利用例を示したものである。
73 $\fB kill \-QUIT %1\fP
74 Signal handling thread got signal 3
75 $\fB kill \-USR1 %1\fP
76 Signal handling thread got signal 10
77 $\fB kill \-TERM %1\fP
78 [1]+ Terminated ./a.out
91 /* Simple error handling functions */
93 #define handle_error_en(en, msg) \e
94 do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
103 s = sigwait(set, &sig);
105 handle_error_en(s, "sigwait");
106 printf("Signal handling thread got signal %d\en", sig);
111 main(int argc, char *argv[])
117 /* Block SIGQUIT and SIGUSR1; other threads created by main()
118 will inherit a copy of the signal mask. */
121 sigaddset(&set, SIGQUIT);
122 sigaddset(&set, SIGUSR1);
123 s = pthread_sigmask(SIG_BLOCK, &set, NULL);
125 handle_error_en(s, "pthread_sigmask");
127 s = pthread_create(&thread, NULL, &sig_thread, (void *) &set);
129 handle_error_en(s, "pthread_create");
131 /* Main thread carries on to create other threads and/or do
134 pause(); /* Dummy pause so we can test program */
138 \fBsigaction\fP(2), \fBsigpending\fP(2), \fBsigprocmask\fP(2), \fBpthread_create\fP(3),
139 \fBpthread_kill\fP(3), \fBsigsetops\fP(3), \fBpthreads\fP(7), \fBsignal\fP(7)
141 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
142 である。プロジェクトの説明とバグ報告に関する情報は
143 http://www.kernel.org/doc/man\-pages/ に書かれている。