SIGVEC(2)
SIGVEC(2) π the software signal facilities page, bestie
okay so this is sigvec(2) from the System Calls Manual, and it lives in the Standard C Library (libc, -lc). grab a snack, we're going in π
β¨ NAME β¨
sigvec β software signal facilities π
π LIBRARY π
Standard C Library (libc, -lc)
π SYNOPSIS π
#include <signal.h>
struct sigvec {
void (*sv_handler)();
int sv_mask;
int sv_flags;
};
int
sigvec(int sig, struct sigvec *vec, struct sigvec *ovec);
π« DESCRIPTION π«
heads up bestie: this interface is made obsolete by sigaction(2). like, it still works, but it's giving vintage. π
So. The system defines a whole set of signals that can be delivered to a process. Signal delivery is basically a hardware interrupt but make it β¨vibesβ¨: the signal gets blocked from happening again, the current process context is saved, and a brand new one is built. A process can name a handler that a signal gets delivered to, or say a signal should be blocked or ignored. A process can also say "hey system, just do the default action" when a signal shows up. Normally, signal handlers run on the current stack of the process. But that can be changed β on a per-handler basis β so signals get taken on a special signal stack. π¦
All signals have the same priority. Signal routines execute with the signal that caused their invocation blocked, but other signals may still occur. There's a global signal mask that defines the set of signals currently blocked from delivery to a process. The signal mask for a process is initialized from that of its parent (normally 0). You can change it with a sigblock(2) or sigsetmask(2) call, or it changes when a signal is delivered to the process.
When a signal condition arises for a process, the signal gets added to a set of signals pending for the process. If the signal isn't currently blocked by the process, it gets delivered to the process. When a signal is delivered, the current state of the process is saved, a new signal mask is calculated (as described below), and the signal handler is invoked. The call to the handler is arranged so that if the signal handling routine returns normally, the process resumes execution in the context from before the signal's delivery. If the process wants to resume in a different context, then it has to arrange to restore the previous context itself. no cap. π€
When a signal is delivered to a process, a new signal mask is installed for the duration of the process' signal handler (or until a sigblock(2) or sigsetmask(2) call is made). This mask is formed by taking the current signal mask, adding the signal to be delivered, and or'ing in the signal mask associated with the handler to be invoked.
The sigvec() function assigns a handler for a specific signal. If vec is non-zero, it specifies a handler routine and mask to be used when delivering the specified signal. Further, if the SV_ONSTACK bit is set in sv_flags, the system will deliver the signal to the process on a signal stack, specified with sigaltstack(2). If ovec is non-zero, the previous handling information for the signal is returned to the user. π«Ά
Here's the full list of all signals, with names as in the include file <signal.h>:
SIGHUPβ Default action: terminate process β terminal line hangupSIGINTβ Default action: terminate process β interrupt programSIGQUITβ Default action: create core image β quit programSIGILLβ Default action: create core image β illegal instructionSIGTRAPβ Default action: create core image β trace trapSIGABRTβ Default action: create core image βabort(3)call (formerlySIGIOT)SIGEMTβ Default action: create core image β emulate instruction executedSIGFPEβ Default action: create core image β floating-point exceptionSIGKILLβ Default action: terminate process β kill programSIGBUSβ Default action: create core image β bus errorSIGSEGVβ Default action: create core image β segmentation violationSIGSYSβ Default action: create core image β non-existent system call invokedSIGPIPEβ Default action: terminate process β write on a pipe with no readerSIGALRMβ Default action: terminate process β real-time timer expiredSIGTERMβ Default action: terminate process β software termination signalSIGURGβ Default action: discard signal β urgent condition present on socketSIGSTOPβ Default action: stop process β stop (cannot be caught or ignored)SIGTSTPβ Default action: stop process β stop signal generated from keyboardSIGCONTβ Default action: discard signal β continue after stopSIGCHLDβ Default action: discard signal β child status has changedSIGTTINβ Default action: stop process β background read attempted from control terminalSIGTTOUβ Default action: stop process β background write attempted to control terminalSIGIOβ Default action: discard signal β I/O is possible on a descriptor (seefcntl(2))SIGXCPUβ Default action: terminate process β cpu time limit exceeded (seesetrlimit(2))SIGXFSZβ Default action: terminate process β file size limit exceeded (seesetrlimit(2))SIGVTALRMβ Default action: terminate process β virtual time alarm (seesetitimer(2))SIGPROFβ Default action: terminate process β profiling timer alarm (seesetitimer(2))SIGWINCHβ Default action: discard signal β Window size changeSIGINFOβ Default action: discard signal β status request from keyboardSIGUSR1β Default action: terminate process β User defined signal 1SIGUSR2β Default action: terminate process β User defined signal 2
Once a signal handler is installed, it stays installed until another sigvec() call is made, or an execve(2) is performed. You can reset a signal-specific default action by setting sv_handler to SIG_DFL. The defaults are process termination (possibly with core dump), no action, stopping the process, or continuing the process β check the signal list above for each signal's default action. If sv_handler is SIG_IGN, current and pending instances of the signal are ignored and discarded. π
If a signal is caught during the system calls listed below, the call is normally restarted. You can force the call to terminate prematurely with an EINTR error return by setting the SV_INTERRUPT bit in sv_flags. The affected system calls include read(2), write(2), sendto(2), recvfrom(2), sendmsg(2) and recvmsg(2) on a communications channel or a slow device (such as a terminal, but not a regular file) and during a wait(2) or ioctl(2). However, calls that have already committed are not restarted β instead they return a partial success (for example, a short read count). π
After a fork(2) or vfork(2), all signals, the signal mask, the signal stack, and the restart/interrupt flags are inherited by the child. πΈ
The execve(2) system call reinstates the default action for all signals which were caught and resets all signals to be caught on the user stack. Ignored signals remain ignored; the signal mask remains the same; signals that interrupt system calls continue to do so.
π NOTES π
The mask specified in vec is not allowed to block SIGKILL or SIGSTOP. This is done silently by the system. π
The SV_INTERRUPT flag is not available in 4.2BSD, hence it should not be used if backward compatibility is needed.
π― RETURN VALUES π―
The sigvec() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. slay or fail, no in-between π
π EXAMPLES π
On the VAX-11, the handler routine can be declared:
void handler(sig, code, scp)
int sig, code;
struct sigcontext *scp;
Here sig is the signal number, into which the hardware faults and traps are mapped as defined below. The code argument is either a constant as given below or, for compatibility mode faults, the code provided by the hardware (Compatibility mode faults are distinguished from the other SIGILL traps by having PSL_CM set in the psl). The scp argument is a pointer to the sigcontext structure (defined in <signal.h>), used to restore the context from before the signal.
π¨ ERRORS π¨
The sigvec() function will fail and no new signal handler will be installed if one of the following occurs:
[EFAULT]β Eithervecorovecpoints to memory that is not a valid part of the process address space.[EINVAL]β Thesigargument is not a valid signal number.[EINVAL]β An attempt is made to ignore or supply a handler forSIGKILLorSIGSTOP.
π SEE ALSO π
kill(1), kill(2), ptrace(2), sigaction(2), sigaltstack(2), sigblock(2), sigpause(2), sigprocmask(2), sigsetmask(2), sigsuspend(2), setjmp(3), siginterrupt(3), signal(3), sigsetops(3), tty(4)
π BUGS π
This manual page is still confusing. (literally same, bestie π)
okay that's the whole page, mwah π this one came from Debian, dated April 19, 1994 β yeah it's giving 90s but the signal handling still hits. go forth and sigvec() responsibly, ily, bye β¨π¦π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1980, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms