Provided by: manpages-fr-dev_4.13-4_all bug

NOM

       pthread_sigmask - Examiner et modifier le masque des signaux bloqués

SYNOPSIS

       #include <signal.h>

       int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);

       Compiler et éditer les liens avec -pthreads.

   Exigences de macros de test de fonctionnalités pour la glibc (consulter feature_test_macros(7)) :

       pthread_sigmask() :
           _POSIX_C_SOURCE >= 199506L || _XOPEN_SOURCE >= 500

DESCRIPTION

       The  pthread_sigmask()   function  is  just  like  sigprocmask(2),  with  the  difference that its use in
       multithreaded programs is explicitly specified by POSIX.1. Other differences are noted in this page.

       Pour une description des arguments et du mode d'opération de cette fonction, consultez sigprocmask(2).

VALEUR RENVOYÉE

       En cas de réussite, pthread_sigmask() renvoie 0 ; en cas d'erreur, elle renvoie un numéro d'erreur.

ERREURS

       Consultez sigprocmask(2).

ATTRIBUTS

       Pour une explication des termes utilisés dans cette section, consulter attributes(7).
       ┌───────────────────┬──────────────────────┬─────────┐
       │ InterfaceAttributValeur  │
       ├───────────────────┼──────────────────────┼─────────┤
       │ pthread_sigmask() │ Sécurité des threads │ MT-Safe │
       └───────────────────┴──────────────────────┴─────────┘

CONFORMITÉ

       POSIX.1-2001, POSIX.1-2008.

NOTES

       Un nouveau thread hérite d'une copie du masque de signaux de son créateur.

       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.

EXEMPLES

       Le  programme ci-dessous bloque certains signaux dans le thread principal, puis crée un thread dédié pour
       récupérer ces signaux  avec  sigwait(3).  La  session  d'interpréteur  de  commande  ci-dessous  démontre
       l'utilisation du programme.

           $ ./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

   Source du programme

       #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 */
       }

VOIR AUSSI

       sigaction(2),    sigpending(2),    sigprocmask(2),    pthread_attr_setsigmask_np(3),   pthread_create(3),
       pthread_kill(3), sigsetops(3), pthreads(7), signal(7)

COLOPHON

       Cette page fait partie de la publication 5.10 du projet man-pages Linux. Une description du projet et des
       instructions pour signaler des anomalies et la dernière version de cette page  peuvent  être  trouvées  à
       l'adresse https://www.kernel.org/doc/man-pages/.

TRADUCTION

       La   traduction   française   de   cette   page   de   manuel   a   été   créée   par  Christophe  Blaess
       <https://www.blaess.fr/christophe/>,   Stéphan   Rafin   <stephan.rafin@laposte.net>,   Thierry   Vignaud
       <tvignaud@mandriva.com>,  François  Micaux,  Alain Portal <aportal@univ-montp2.fr>, Jean-Philippe Guérard
       <fevrier@tigreraye.org>,   Jean-Luc   Coulon   (f5ibh)   <jean-luc.coulon@wanadoo.fr>,   Julien   Cristau
       <jcristau@debian.org>,      Thomas      Huriaux      <thomas.huriaux@gmail.com>,     Nicolas     François
       <nicolas.francois@centraliens.net>,    Florentin    Duneau    <fduneau@gmail.com>,     Simon     Paillard
       <simon.paillard@resel.enst-bretagne.fr>,     Denis    Barbier    <barbier@debian.org>,    David    Prévot
       <david@tilapin.org> et Frédéric Hantrais <fhantrais@gmail.com>

       Cette traduction est une documentation libre ; veuillez vous  reporter  à  la  GNU General Public License
       version 3 concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.

       Si  vous  découvrez  un  bogue  dans la traduction de cette page de manuel, veuillez envoyer un message à
       debian-l10n-french@lists.debian.org.

Linux                                            1 novembre 2020                              PTHREAD_SIGMASK(3)