signal.h (2025B)
1 #ifndef _SIGNAL_H 2 #define _SIGNAL_H 3 4 #include <sys/types.h> 5 6 7 /* Signal-related types */ 8 typedef void (*sighandler_t)(int); 9 typedef unsigned long sigset_t; 10 struct sigaction; 11 12 /* Signal numbers */ 13 #define SIGHUP 1 14 #define SIGINT 2 15 #define SIGQUIT 3 16 #define SIGILL 4 17 #define SIGTRAP 5 18 #define SIGABRT 6 19 #define SIGBUS 7 20 #define SIGFPE 8 21 #define SIGKILL 9 22 #define SIGUSR1 10 23 #define SIGSEGV 11 24 #define SIGUSR2 12 25 #define SIGPIPE 13 26 #define SIGALRM 14 27 #define SIGTERM 15 28 #define SIGCHLD 17 29 #define SIGCONT 18 30 #define SIGSTOP 19 31 #define SIGTSTP 20 32 #define SIGTTIN 21 33 #define SIGTTOU 22 34 #define SIGURG 23 35 #define SIGXCPU 24 36 #define SIGXFSZ 25 37 #define SIGVTALRM 26 38 #define SIGPROF 27 39 #define SIGPOLL 29 40 #define SIGSYS 31 41 42 43 /* Special signal function values */ 44 #define SIG_ERR ((sighandler_t)-1) 45 #define SIG_DFL ((sighandler_t)0) 46 #define SIG_IGN ((sighandler_t)1) 47 #define SIG_HOLD ((sighandler_t)2) 48 49 50 /* Signal handling */ 51 struct sigaction { 52 union { 53 void (*sa_handler)(int); 54 void (*sa_sigaction)(int siginfo_t, void*); 55 }; 56 sigset_t sa_mask; 57 int sa_flags; 58 }; 59 60 #define SA_NOCLDSTOP 0x0001 61 #define SA_NOCLDWAIT 0x0002 62 #define SA_NODEFER 0x0004 63 #define SA_SIGINFO 0x0008 64 #define SA_ONSTACK 0x0010 65 #define SA_RESETHAND 0x0020 66 #define SA_RESTART 0x0040 67 68 69 typedef volatile int sig_atomic_t; 70 71 72 /* Signal sets */ 73 int sigemptyset(sigset_t *set); 74 int sigfillset(sigset_t *set); 75 int sigaddset(sigset_t *set, int sig); 76 int sigdelset(sigset_t *set, int sig); 77 int sigismember(const sigset_t *set, int sig); 78 79 /* Signal generation */ 80 int kill(pid_t target, int sig); 81 int raise(int sig); 82 83 /* Signal management */ 84 sighandler_t signal(int sig, sighandler_t handler); 85 int sigaction(int sig, const struct sigaction *__restrict act, 86 struct sigaction *__restrict oldact); 87 int sigprocmask(int how, const sigset_t *__restrict set, 88 sigset_t *__restrict oldset); 89 int sigpending(sigset_t *set); 90 int sigsuspend(const sigset_t *mask); 91 int sigwait(const sigset_t *__restrict set, int *__restrict sig); 92 93 94 #endif // _SIGNAL_H