Provided by: manpages-ja-dev_0.5.0.0.20221215+dfsg-1_all 
      
    
名前
       pthread_sigmask - 禁止するシグナルマスクの確認と変更を行う
書式
       #include <signal.h>
       int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
       -pthread を付けてコンパイルとリンクを行う。
   glibc 向けの機能検査マクロの要件 (feature_test_macros(7)  参照):
       pthread_sigmask():
           _POSIX_C_SOURCE >= 199506L || _XOPEN_SOURCE >= 500
説明
       pthread_sigmask() 関数は sigprocmask(2) と全く同様だが、マルチスレッドプログラムでの利用が POSIX.1 で明示
       的に規定されている点が異なる。他の違いはこのマニュアルページで説明する。
       この関数の引数と動作の説明は sigprocmask(2) を参照。
返り値
       成功すると、 pthread_sigmask() は 0 を返す。 エラーの場合、エラー番号を返す。
エラー
       sigprocmask(2) を参照。
属性
       この節で使用されている用語の説明については、 attributes(7) を参照。
       ┌───────────────────┬───────────────┬─────────┐
       │ インターフェース  │ 属性          │ 値      │
       ├───────────────────┼───────────────┼─────────┤
       │ pthread_sigmask() │ Thread safety │ MT-Safe │
       └───────────────────┴───────────────┴─────────┘
準拠
       POSIX.1-2001, POSIX.1-2008.
注意
       新しいスレッドは、スレッドを作成したスレッドのシグナルマスクのコピーを 継承する。
       The  glibc  pthread_sigmask()  function silently ignores attempts to block the two real-time signals that
       are used internally by the NPTL threading implementation.  See nptl(7)  for details.
例
       以下のプログラムは、メインスレッドでシグナルのいくつかを禁止 (block) するように設定を行い、 sigwait(3) 経
       由でそれらのシグナルを集める 専用のスレッドを作成する。  下記のシェルのセッションはその利用例を示したもの
       である。
           $ ./a.out &
           [1] 5423
           $ kill -QUIT %1
           Signal handling thread got signal 3
           $ kill -USR1 %1
           Signal handling thread got signal 10
           $ kill -TERM %1
           [1]+  Terminated              ./a.out
   プログラムのソース
       #include <pthread.h>
       #include <stdio.h>
       #include <stdlib.h>
       #include <unistd.h>
       #include <signal.h>
       #include <errno.h>
       /* Simple error handling functions */
       #define handle_error_en(en, msg) \
               do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
       static void *
       sig_thread(void *arg)
       {
           sigset_t *set = arg;
           int s, sig;
           for (;;) {
               s = sigwait(set, &sig);
               if (s != 0)
                   handle_error_en(s, "sigwait");
               printf("Signal handling thread got signal %d\n", sig);
           }
       }
       int
       main(int argc, char *argv[])
       {
           pthread_t thread;
           sigset_t set;
           int s;
           /* Block SIGQUIT and SIGUSR1; other threads created by main()
              will inherit a copy of the signal mask. */
           sigemptyset(&set);
           sigaddset(&set, SIGQUIT);
           sigaddset(&set, SIGUSR1);
           s = pthread_sigmask(SIG_BLOCK, &set, NULL);
           if (s != 0)
               handle_error_en(s, "pthread_sigmask");
           s = pthread_create(&thread, NULL, &sig_thread, &set);
           if (s != 0)
               handle_error_en(s, "pthread_create");
           /* Main thread carries on to create other threads and/or do
              other work */
           pause();            /* Dummy pause so we can test program */
       }
関連項目
       sigaction(2),    sigpending(2),    sigprocmask(2),    pthread_attr_setsigmask_np(3),   pthread_create(3),
       pthread_kill(3), sigsetops(3), pthreads(7), signal(7)
この文書について
       この man ページは Linux man-pages プロジェクトのリリース 5.10  の一部である。プロジェクトの説明とバグ報告
       に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。
Linux                                              2020-11-01                                 PTHREAD_SIGMASK(3)