sigprocmask(2) — Linux manual page


SIGPROCMASK(2)            Linux Programmer's Manual           SIGPROCMASK(2)

NAME         top

       sigprocmask, rt_sigprocmask - examine and change blocked signals

SYNOPSIS         top

       #include <signal.h>

       /* Prototype for the glibc wrapper function */
       int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);

       /* Prototype for the underlying system call */
       int rt_sigprocmask(int how, const kernel_sigset_t *set,
                          kernel_sigset_t *oldset, size_t sigsetsize);

       /* Prototype for the legacy system call (deprecated) */
       int sigprocmask(int how, const old_kernel_sigset_t *set,
                       old_kernel_sigset_t *oldset);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       sigprocmask(): _POSIX_C_SOURCE

DESCRIPTION         top

       sigprocmask() is used to fetch and/or change the signal mask of the
       calling thread.  The signal mask is the set of signals whose delivery
       is currently blocked for the caller (see also signal(7) for more

       The behavior of the call is dependent on the value of how, as

              The set of blocked signals is the union of the current set and
              the set argument.

              The signals in set are removed from the current set of blocked
              signals.  It is permissible to attempt to unblock a signal
              which is not blocked.

              The set of blocked signals is set to the argument set.

       If oldset is non-NULL, the previous value of the signal mask is
       stored in oldset.

       If set is NULL, then the signal mask is unchanged (i.e., how is
       ignored), but the current value of the signal mask is nevertheless
       returned in oldset (if it is not NULL).

       A set of functions for modifying and inspecting variables of type
       sigset_t ("signal sets") is described in sigsetops(3).

       The use of sigprocmask() is unspecified in a multithreaded process;
       see pthread_sigmask(3).

RETURN VALUE         top

       sigprocmask() returns 0 on success and -1 on error.  In the event of
       an error, errno is set to indicate the cause.

ERRORS         top

       EFAULT The set or oldset argument points outside the process's
              allocated address space.

       EINVAL Either the value specified in how was invalid or the kernel
              does not support the size passed in sigsetsize.

CONFORMING TO         top

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

NOTES         top

       It is not possible to block SIGKILL or SIGSTOP.  Attempts to do so
       are silently ignored.

       Each of the threads in a process has its own signal mask.

       A child created via fork(2) inherits a copy of its parent's signal
       mask; the signal mask is preserved across execve(2).

       If SIGBUS, SIGFPE, SIGILL, or SIGSEGV are generated while they are
       blocked, the result is undefined, unless the signal was generated by
       kill(2), sigqueue(3), or raise(3).

       See sigsetops(3) for details on manipulating signal sets.

       Note that it is permissible (although not very useful) to specify
       both set and oldset as NULL.

   C library/kernel differences
       The kernel's definition of sigset_t differs in size from that used by
       the C library.  In this manual page, the former is referred to as
       kernel_sigset_t (it is nevertheless named sigset_t in the kernel

       The glibc wrapper function for sigprocmask() silently ignores
       attempts to block the two real-time signals that are used internally
       by the NPTL threading implementation.  See nptl(7) for details.

       The original Linux system call was named sigprocmask().  However,
       with the addition of real-time signals in Linux 2.2, the fixed-size,
       32-bit sigset_t (referred to as old_kernel_sigset_t in this manual
       page) type supported by that system call was no longer fit for
       purpose.  Consequently, a new system call, rt_sigprocmask(), was
       added to support an enlarged sigset_t type (referred to as
       kernel_sigset_t in this manual page).  The new system call takes a
       fourth argument, size_t sigsetsize, which specifies the size in bytes
       of the signal sets in set and oldset.  This argument is currently
       required to have a fixed architecture specific value (equal to

       The glibc sigprocmask() wrapper function hides these details from us,
       transparently calling rt_sigprocmask() when the kernel provides it.

SEE ALSO         top

       kill(2), pause(2), sigaction(2), signal(2), sigpending(2),
       sigsuspend(2), pthread_sigmask(3), sigqueue(3), sigsetops(3),

COLOPHON         top

       This page is part of release 5.09 of the Linux man-pages project.  A
       description of the project, information about reporting bugs, and the
       latest version of this page, can be found at

Linux                            2017-09-15                   SIGPROCMASK(2)

Pages that refer to this page: env(1)clone2(2)__clone2(2)clone(2)clone3(2)_newselect(2)poll(2)ppoll(2)pselect(2)pselect6(2)ptrace(2)rt_sigaction(2)rt_sigpending(2)rt_sigqueueinfo(2)rt_sigsuspend(2)rt_sigtimedwait(2)rt_tgsigqueueinfo(2)seccomp(2)select(2)select_tut(2)sgetmask(2)sigaction(2)signal(2)signalfd(2)signalfd4(2)sigpending(2)sigsuspend(2)sigtimedwait(2)sigwaitinfo(2)ssetmask(2)syscalls(2)aiocb(3)clockid_t(3)clock_t(3)dev_t(3)div_t(3)double_t(3)fd_clr(3)FD_CLR(3)fd_isset(3)FD_ISSET(3)fd_set(3)FD_SET(3)fd_zero(3)FD_ZERO(3)fenv_t(3)fexcept_t(3)file(3)FILE(3)float_t(3)getcontext(3)gid_t(3)id_t(3)imaxdiv_t(3)int16_t(3)int32_t(3)int64_t(3)int8_t(3)intmax_t(3)intn_t(3)intN_t(3)intptr_t(3)lconv(3)ldiv_t(3)lldiv_t(3)makecontext(3)off_t(3)pid_t(3)posix_spawn(3)posix_spawnp(3)pthread_attr_getsigmask_np(3)pthread_attr_setsigmask_np(3)pthread_sigmask(3)ptrdiff_t(3)regex_t(3)regmatch_t(3)regoff_t(3)sd_event_add_child(3)sd_event_add_child_pidfd(3)sd_event_add_signal(3)sd_event_child_handler_t(3)sd_event_signal_handler_t(3)sd_event_source_get_child_pid(3)sd_event_source_get_child_pidfd(3)sd_event_source_get_child_pidfd_own(3)sd_event_source_get_child_process_own(3)sd_event_source_get_signal(3)sd_event_source_send_child_signal(3)sd_event_source_set_child_pidfd_own(3)sd_event_source_set_child_process_own(3)setcontext(3)sigaddset(3)sigandset(3)sigblock(3)sigdelset(3)sigemptyset(3)sigfillset(3)siggetmask(3)sighold(3)sigignore(3)siginfo_t(3)sigisemptyset(3)sigismember(3)sigmask(3)sigorset(3)sigpause(3)sigrelse(3)sigset(3)sigsetmask(3)sigsetops(3)sigset_t(3)sigval(3)sigvec(3)size_t(3)ssize_t(3)suseconds_t(3)swapcontext(3)system(3)timer_t(3)timespec(3)time_t(3)timeval(3)uid_t(3)uint16_t(3)uint32_t(3)uint64_t(3)uint8_t(3)uintmax_t(3)uintn_t(3)uintN_t(3)uintptr_t(3)va_list(3)void(3)systemd.exec(5)nptl(7)signal(7)signal-safety(7)system_data_types(7)