modernc.org/cc@v1.0.1/v2/headers/linux_386/usr/include/signal.h (about) 1 /* Copyright (C) 1991-2018 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <http://www.gnu.org/licenses/>. */ 17 18 /* 19 * ISO C99 Standard: 7.14 Signal handling <signal.h> 20 */ 21 22 #ifndef _SIGNAL_H 23 #define _SIGNAL_H 24 25 #include <features.h> 26 27 __BEGIN_DECLS 28 #include <bits/types.h> 29 #include <bits/signum.h> 30 #include <bits/types/sig_atomic_t.h> 31 #if defined __USE_POSIX 32 #include <bits/types/sigset_t.h> 33 #endif 34 #if defined __USE_XOPEN || defined __USE_XOPEN2K 35 # ifndef __pid_t_defined 36 typedef __pid_t pid_t; 37 # define __pid_t_defined 38 #endif 39 #ifdef __USE_XOPEN 40 # endif 41 # ifndef __uid_t_defined 42 typedef __uid_t uid_t; 43 # define __uid_t_defined 44 # endif 45 #endif /* Unix98 */ 46 47 #ifdef __USE_POSIX199309 48 /* We need `struct timespec' later on. */ 49 # include <bits/types/struct_timespec.h> 50 #endif 51 52 #if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED 53 # include <bits/types/siginfo_t.h> 54 # include <bits/siginfo-consts.h> 55 #endif 56 57 #ifdef __USE_MISC 58 # include <bits/types/sigval_t.h> 59 #endif 60 61 #ifdef __USE_POSIX199309 62 # include <bits/types/sigevent_t.h> 63 # include <bits/sigevent-consts.h> 64 #endif 65 66 /* Type of a signal handler. */ 67 typedef void (*__sighandler_t) (int); 68 69 /* The X/Open definition of `signal' specifies the SVID semantic. Use 70 the additional function `sysv_signal' when X/Open compatibility is 71 requested. */ 72 extern __sighandler_t __sysv_signal(int __sig, __sighandler_t __handler) __THROW; 73 #ifdef __USE_GNU 74 extern __sighandler_t sysv_signal(int __sig, __sighandler_t __handler) __THROW; 75 #endif 76 77 /* Set the handler for the signal SIG to HANDLER, returning the old 78 handler, or SIG_ERR on error. 79 By default `signal' has the BSD semantic. */ 80 #ifdef __USE_MISC 81 extern __sighandler_t signal(int __sig, __sighandler_t __handler) __THROW; 82 #else 83 /* Make sure the used `signal' implementation is the SVID version. */ 84 # ifdef __REDIRECT_NTH 85 extern __sighandler_t __REDIRECT_NTH(signal, (int __sig, __sighandler_t __handler), __sysv_signal); 86 # else 87 # define signal __sysv_signal 88 # endif 89 #endif 90 91 #if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8 92 /* The X/Open definition of `signal' conflicts with the BSD version. 93 So they defined another function `bsd_signal'. */ 94 extern __sighandler_t bsd_signal(int __sig, __sighandler_t __handler) __THROW; 95 #endif 96 97 /* Send signal SIG to process number PID. If PID is zero, 98 send SIG to all processes in the current process's process group. 99 If PID is < -1, send SIG to all processes in process group - PID. */ 100 #ifdef __USE_POSIX 101 extern int kill(__pid_t __pid, int __sig) __THROW; 102 #endif /* Use POSIX. */ 103 104 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED 105 /* Send SIG to all processes in process group PGRP. 106 If PGRP is zero, send SIG to all processes in 107 the current process's process group. */ 108 extern int killpg(__pid_t __pgrp, int __sig) __THROW; 109 #endif /* Use misc || X/Open Unix. */ 110 111 /* Raise signal SIG, i.e., send SIG to yourself. */ 112 extern int raise(int __sig) __THROW; 113 114 #ifdef __USE_MISC 115 /* SVID names for the same things. */ 116 extern __sighandler_t ssignal(int __sig, __sighandler_t __handler) __THROW; 117 extern int gsignal(int __sig) __THROW; 118 #endif /* Use misc. */ 119 120 #ifdef __USE_XOPEN2K8 121 /* Print a message describing the meaning of the given signal number. */ 122 extern void psignal(int __sig, const char *__s); 123 124 /* Print a message describing the meaning of the given signal information. */ 125 extern void psiginfo(const siginfo_t * __pinfo, const char *__s); 126 #endif /* POSIX 2008. */ 127 128 /* The `sigpause' function in X/Open defines the argument as the 129 signal number. This requires redirecting to another function 130 because the default version in glibc uses an old BSD interface. 131 132 This function is a cancellation point and therefore not marked with 133 __THROW. */ 134 135 #ifdef __USE_XOPEN_EXTENDED 136 # ifdef __GNUC__ 137 extern int sigpause(int __sig) __asm__("__xpg_sigpause"); 138 # else 139 extern int __sigpause(int __sig_or_mask, int __is_sig); 140 /* Remove a signal from the signal mask and suspend the process. */ 141 # define sigpause(sig) __sigpause ((sig), 1) 142 # endif 143 #endif 144 145 #ifdef __USE_MISC 146 /* None of the following functions should be used anymore. They are here 147 only for compatibility. A single word (`int') is not guaranteed to be 148 enough to hold a complete signal mask and therefore these functions 149 simply do not work in many situations. Use `sigprocmask' instead. */ 150 151 /* Compute mask for signal SIG. */ 152 # define sigmask(sig) ((int)(1u << ((sig) - 1))) 153 154 /* Block signals in MASK, returning the old mask. */ 155 extern int sigblock(int __mask) 156 __THROW __attribute_deprecated__; 157 158 /* Set the mask of blocked signals to MASK, returning the old mask. */ 159 extern int sigsetmask(int __mask) 160 __THROW __attribute_deprecated__; 161 162 /* Return currently selected signal mask. */ 163 extern int siggetmask(void) 164 __THROW __attribute_deprecated__; 165 #endif /* Use misc. */ 166 167 #ifdef __USE_MISC 168 # define NSIG _NSIG 169 #endif 170 171 #ifdef __USE_GNU 172 typedef __sighandler_t sighandler_t; 173 #endif 174 175 /* 4.4 BSD uses the name `sig_t' for this. */ 176 #ifdef __USE_MISC 177 typedef __sighandler_t sig_t; 178 #endif 179 180 #ifdef __USE_POSIX 181 182 /* Clear all signals from SET. */ 183 extern int sigemptyset(sigset_t * __set) 184 __THROW __nonnull((1)); 185 186 /* Set all signals in SET. */ 187 extern int sigfillset(sigset_t * __set) 188 __THROW __nonnull((1)); 189 190 /* Add SIGNO to SET. */ 191 extern int sigaddset(sigset_t * __set, int __signo) 192 __THROW __nonnull((1)); 193 194 /* Remove SIGNO from SET. */ 195 extern int sigdelset(sigset_t * __set, int __signo) 196 __THROW __nonnull((1)); 197 198 /* Return 1 if SIGNO is in SET, 0 if not. */ 199 extern int sigismember(const sigset_t * __set, int __signo) 200 __THROW __nonnull((1)); 201 202 # ifdef __USE_GNU 203 /* Return non-empty value is SET is not empty. */ 204 extern int sigisemptyset(const sigset_t * __set) 205 __THROW __nonnull((1)); 206 207 /* Build new signal set by combining the two inputs set using logical AND. */ 208 extern int sigandset(sigset_t * __set, const sigset_t * __left, const sigset_t * __right) 209 __THROW __nonnull((1, 2, 3)); 210 211 /* Build new signal set by combining the two inputs set using logical OR. */ 212 extern int sigorset(sigset_t * __set, const sigset_t * __left, const sigset_t * __right) 213 __THROW __nonnull((1, 2, 3)); 214 # endif /* GNU */ 215 216 /* Get the system-specific definitions of `struct sigaction' 217 and the `SA_*' and `SIG_*'. constants. */ 218 # include <bits/sigaction.h> 219 220 /* Get and/or change the set of blocked signals. */ 221 extern int sigprocmask(int __how, const sigset_t * __restrict __set, sigset_t * __restrict __oset) __THROW; 222 223 /* Change the set of blocked signals to SET, 224 wait until a signal arrives, and restore the set of blocked signals. 225 226 This function is a cancellation point and therefore not marked with 227 __THROW. */ 228 extern int sigsuspend(const sigset_t * __set) __nonnull((1)); 229 230 /* Get and/or set the action for signal SIG. */ 231 extern int sigaction(int __sig, const struct sigaction *__restrict __act, struct sigaction *__restrict __oact) __THROW; 232 233 /* Put in SET all signals that are blocked and waiting to be delivered. */ 234 extern int sigpending(sigset_t * __set) 235 __THROW __nonnull((1)); 236 237 # ifdef __USE_POSIX199506 238 /* Select any of pending signals from SET or wait for any to arrive. 239 240 This function is a cancellation point and therefore not marked with 241 __THROW. */ 242 extern int sigwait(const sigset_t * __restrict __set, int *__restrict __sig) __nonnull((1, 2)); 243 # endif /* Use POSIX 1995. */ 244 245 # ifdef __USE_POSIX199309 246 /* Select any of pending signals from SET and place information in INFO. 247 248 This function is a cancellation point and therefore not marked with 249 __THROW. */ 250 extern int sigwaitinfo(const sigset_t * __restrict __set, siginfo_t * __restrict __info) __nonnull((1)); 251 252 /* Select any of pending signals from SET and place information in INFO. 253 Wait the time specified by TIMEOUT if no signal is pending. 254 255 This function is a cancellation point and therefore not marked with 256 __THROW. */ 257 extern int sigtimedwait(const sigset_t * __restrict __set, siginfo_t * __restrict __info, const struct timespec *__restrict __timeout) __nonnull((1)); 258 259 /* Send signal SIG to the process PID. Associate data in VAL with the 260 signal. */ 261 extern int sigqueue(__pid_t __pid, int __sig, const union sigval __val) __THROW; 262 # endif /* Use POSIX 199306. */ 263 264 #endif /* Use POSIX. */ 265 266 #ifdef __USE_MISC 267 268 /* Names of the signals. This variable exists only for compatibility. 269 Use `strsignal' instead (see <string.h>). */ 270 extern const char *const _sys_siglist[_NSIG]; 271 extern const char *const sys_siglist[_NSIG]; 272 273 /* Get machine-dependent `struct sigcontext' and signal subcodes. */ 274 # include <bits/sigcontext.h> 275 276 /* Restore the state saved in SCP. */ 277 extern int sigreturn(struct sigcontext *__scp) __THROW; 278 279 #endif /* Use misc. */ 280 281 #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 282 # define __need_size_t 283 # include <stddef.h> 284 285 # include <bits/types/stack_t.h> 286 # if defined __USE_XOPEN || defined __USE_XOPEN2K8 287 /* This will define `ucontext_t' and `mcontext_t'. */ 288 # include <sys/ucontext.h> 289 # endif 290 #endif /* Use POSIX.1-2008 or X/Open Unix. */ 291 292 #if defined __USE_XOPEN_EXTENDED || defined __USE_MISC 293 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls 294 (causing them to fail with EINTR); if INTERRUPT is zero, make system 295 calls be restarted after signal SIG. */ 296 extern int siginterrupt(int __sig, int __interrupt) __THROW; 297 298 # include <bits/sigstack.h> 299 # include <bits/ss_flags.h> 300 301 /* Alternate signal handler stack interface. 302 This interface should always be preferred over `sigstack'. */ 303 extern int sigaltstack(const stack_t * __restrict __ss, stack_t * __restrict __oss) __THROW; 304 #endif /* __USE_XOPEN_EXTENDED || __USE_MISC */ 305 306 #if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ 307 || defined __USE_MISC) 308 # include <bits/types/struct_sigstack.h> 309 #endif 310 311 #if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \ 312 || defined __USE_MISC) 313 /* Run signals handlers on the stack specified by SS (if not NULL). 314 If OSS is not NULL, it is filled in with the old signal stack status. 315 This interface is obsolete and on many platform not implemented. */ 316 extern int sigstack(struct sigstack *__ss, struct sigstack *__oss) 317 __THROW __attribute_deprecated__; 318 #endif 319 320 #ifdef __USE_XOPEN_EXTENDED 321 /* Simplified interface for signal management. */ 322 323 /* Add SIG to the calling process' signal mask. */ 324 extern int sighold(int __sig) __THROW; 325 326 /* Remove SIG from the calling process' signal mask. */ 327 extern int sigrelse(int __sig) __THROW; 328 329 /* Set the disposition of SIG to SIG_IGN. */ 330 extern int sigignore(int __sig) __THROW; 331 332 /* Set the disposition of SIG. */ 333 extern __sighandler_t sigset(int __sig, __sighandler_t __disp) __THROW; 334 #endif 335 336 #if defined __USE_POSIX199506 || defined __USE_UNIX98 337 /* Some of the functions for handling signals in threaded programs must 338 be defined here. */ 339 # include <bits/pthreadtypes.h> 340 # include <bits/sigthread.h> 341 #endif /* use Unix98 */ 342 343 /* The following functions are used internally in the C library and in 344 other code which need deep insights. */ 345 346 /* Return number of available real-time signal with highest priority. */ 347 extern int __libc_current_sigrtmin(void) __THROW; 348 /* Return number of available real-time signal with lowest priority. */ 349 extern int __libc_current_sigrtmax(void) __THROW; 350 351 #define SIGRTMIN (__libc_current_sigrtmin ()) 352 #define SIGRTMAX (__libc_current_sigrtmax ()) 353 354 __END_DECLS 355 #endif /* not signal.h */