pthread_attr_setsigmask_np(3) — Linux manual page

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | STANDARDS | HISTORY | NOTES | SEE ALSO | COLOPHON

pthread_...gmask_np(3)  Library Functions Manual  pthread_...gmask_np(3)

NAME         top

       pthread_attr_setsigmask_np, pthread_attr_getsigmask_np - set/get
       signal mask attribute in thread attributes object

LIBRARY         top

       POSIX threads library (libpthread, -lpthread)

SYNOPSIS         top

       #define _GNU_SOURCE             /* See feature_test_macros(7) */
       #include <pthread.h>

       int pthread_attr_setsigmask_np(pthread_attr_t *attr,
                                      const sigset_t *sigmask);
       int pthread_attr_getsigmask_np(const pthread_attr_t *attr,
                                      sigset_t *sigmask);

DESCRIPTION         top

       The pthread_attr_setsigmask_np() function sets the signal mask
       attribute of the thread attributes object referred to by attr to
       the value specified in *sigmask.  If sigmask is specified as
       NULL, then any existing signal mask attribute in attr is unset.

       The pthread_attr_getsigmask_np() function returns the signal mask
       attribute of the thread attributes object referred to by attr in
       the buffer pointed to by sigmask.  If the signal mask attribute
       is currently unset, then this function returns the special value
       PTHREAD_ATTR_NO_SIGMASK_NP as its result.

RETURN VALUE         top

       The pthread_attr_setsigmask_np() function returns 0 on success,
       or a nonzero error number on failure.

       the pthread_attr_getsigmask_np() function returns either 0 or
       PTHREAD_ATTR_NO_SIGMASK_NP.  When 0 is returned, the signal mask
       attribute is returned via sigmask.  A return value of
       PTHREAD_ATTR_NO_SIGMASK_NP indicates that the signal mask
       attribute is not set in attr.

       On error, these functions return a positive error number.

ERRORS         top

       ENOMEM (pthread_attr_setsigmask_np()) Could not allocate memory.

ATTRIBUTES         top

       For an explanation of the terms used in this section, see
       attributes(7).
       ┌─────────────────────────────────────┬───────────────┬─────────┐
       │ Interface                           Attribute     Value   │
       ├─────────────────────────────────────┼───────────────┼─────────┤
       │ pthread_attr_setsigmask_np(),       │ Thread safety │ MT-Safe │
       │ pthread_attr_getsigmask_np()        │               │         │
       └─────────────────────────────────────┴───────────────┴─────────┘

STANDARDS         top

       GNU; hence the suffix "_np" (nonportable) in the names.

HISTORY         top

       glibc 2.32.

NOTES         top

       The signal mask attribute determines the signal mask that will be
       assigned to a thread created using the thread attributes object
       attr.  If this attribute is not set, then a thread created using
       attr will inherit a copy of the creating thread's signal mask.

       For more details on signal masks, see sigprocmask(2).  For a
       description of a set of macros that can be used to manipulate and
       inspect signal sets, see sigsetops(3).

       In the absence of pthread_attr_setsigmask_np() it is possible to
       create a thread with a desired signal mask as follows:

       •  The creating thread uses pthread_sigmask(3) to save its
          current signal mask and set its mask to block all signals.

       •  The new thread is then created using pthread_create(); the new
          thread will inherit the creating thread's signal mask.

       •  The new thread sets its signal mask to the desired value using
          pthread_sigmask(3).

       •  The creating thread restores its signal mask to the original
          value.

       Following the above steps, there is no possibility for the new
       thread to receive a signal before it has adjusted its signal mask
       to the desired value.

SEE ALSO         top

       sigprocmask(2), pthread_attr_init(3), pthread_sigmask(3),
       pthreads(7), signal(7)

COLOPHON         top

       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.9.1.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2024-06-26.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       man-pages@man7.org

Linux man-pages 6.9.1          2024-05-02         pthread_...gmask_np(3)

Pages that refer to this page: pthread_attr_init(3)pthread_sigmask(3)