Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


sigprocmask(2) — Linux manual page

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

sigprocmask(2)             System Calls Manualsigprocmask(2)

NAME        top

       sigprocmask, rt_sigprocmask - examine and change blocked signals

LIBRARY        top

       Standard C library (libc,-lc)

SYNOPSIS        top

#include <signal.h>       /* Prototype for the glibc wrapper function */int sigprocmask(inthow, const sigset_t *_Nullable restrictset,sigset_t *_Nullable restrictoldset);#include <signal.h>/* Definition ofSIG_*constants */#include <sys/syscall.h>/* Definition ofSYS_*constants */#include <unistd.h>       /* Prototype for the underlying system call */int syscall(SYS_rt_sigprocmask, inthow,const kernel_sigset_t *_Nullableset,kernel_sigset_t *_Nullableoldset,size_tsigsetsize);       /* Prototype for the legacy system call */[[deprecated]] int syscall(SYS_sigprocmask, inthow,const old_kernel_sigset_t *_Nullableset,old_kernel_sigset_t *_Nullableoldset);   Feature Test Macro Requirements for glibc (seefeature_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 alsosignal(7)       for more details).       The behavior of the call is dependent on the value ofhow, as       follows.SIG_BLOCK              The set of blocked signals is the union of the current set              and theset argument.SIG_UNBLOCK              The signals inset are removed from the current set of              blocked signals.  It is permissible to attempt to unblock a              signal which is not blocked.SIG_SETMASK              The set of blocked signals is set to the argumentset.       Ifoldset is non-NULL, the previous value of the signal mask is       stored inoldset.       Ifset is NULL, then the signal mask is unchanged (i.e.,how is       ignored), but the current value of the signal mask is nevertheless       returned inoldset (if it is not NULL).       A set of functions for modifying and inspecting variables of typesigset_t ("signal sets") is described insigsetops(3).       The use ofsigprocmask() is unspecified in a multithreaded       process; seepthread_sigmask(3).

RETURN VALUE        top

sigprocmask() returns 0 on success.  On failure, -1 is returned       anderrno is set to indicate the error.

ERRORS        top

EFAULTTheset oroldset argument points outside the process's              allocated address space.EINVALEither the value specified inhow was invalid or the kernel              does not support the size passed insigsetsize.

VERSIONS        top

C library/kernel differences       The kernel's definition ofsigset_t differs in size from that used       by the C library.  In this manual page, the former is referred to       askernel_sigset_t (it is nevertheless namedsigset_t in the       kernel sources).       The glibc wrapper function forsigprocmask() silently ignores       attempts to block the two real-time signals that are used       internally by the NPTL threading implementation.  Seenptl(7) for       details.       The original Linux system call was namedsigprocmask().  However,       with the addition of real-time signals in Linux 2.2, the fixed-       size, 32-bitsigset_t (referred to asold_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 enlargedsigset_t type (referred to askernel_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 inset andoldset.  This argument is       currently required to have a fixed architecture specific value       (equal tosizeof(kernel_sigset_t)).       The glibcsigprocmask() wrapper function hides these details from       us, transparently callingrt_sigprocmask() when the kernel       provides it.

STANDARDS        top

       POSIX.1-2008.

HISTORY        top

       POSIX.1-2001.

NOTES        top

       It is not possible to blockSIGKILLorSIGSTOP.  Attempts to do so       are silently ignored.       Each of the threads in a process has its own signal mask.       A child created viafork(2) inherits a copy of its parent's signal       mask; the signal mask is preserved acrossexecve(2).       IfSIGBUS,SIGFPE,SIGILL, orSIGSEGVare generated while they are       blocked, the result is undefined, unless the signal was generated       bykill(2),sigqueue(3), orraise(3).       Seesigsetops(3) for details on manipulating signal sets.       Note that it is permissible (although not very useful) to specify       bothset andoldset as NULL.

SEE ALSO        top

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

COLOPHON        top

       This page is part of theman-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.15.tar.gz       fetched from       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on       2025-08-11.  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 isnot       part of the original manual page), send a mail to       man-pages@man7.orgLinux man-pages 6.15            2025-05-17sigprocmask(2)

Pages that refer to this page:env(1)clone(2)io_uring_enter2(2)io_uring_enter(2)poll(2)ptrace(2)rt_sigqueueinfo(2)seccomp(2)select(2)select_tut(2)sgetmask(2)sigaction(2)signal(2)signalfd(2)sigpending(2)sigsuspend(2)sigwaitinfo(2)syscalls(2)getcontext(3)makecontext(3)posix_spawn(3)pthread_attr_setsigmask_np(3)pthread_sigmask(3)sd_event_add_child(3)sd_event_add_signal(3)sigpause(3)sigset(3)sigsetops(3)sigvec(3)sigwait(3)system(3)systemd.exec(5)nptl(7)signal(7)signal-safety(7)system_data_types(7)



HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface.

For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere.

Hosting byjambit GmbH.

Cover of TLPI


[8]ページ先頭

©2009-2025 Movatter.jp