1 /* 2 * Copyright (c) 2018 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ 7 #define ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ 8 9 /* include posix_types.h before posix_features.h (here) to avoid build errors against newlib */ 10 #include <zephyr/posix/posix_types.h> 11 #include "posix_features.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #define SIGHUP 1 /**< Hangup */ 18 #define SIGINT 2 /**< Interrupt */ 19 #define SIGQUIT 3 /**< Quit */ 20 #define SIGILL 4 /**< Illegal instruction */ 21 #define SIGTRAP 5 /**< Trace/breakpoint trap */ 22 #define SIGABRT 6 /**< Aborted */ 23 #define SIGBUS 7 /**< Bus error */ 24 #define SIGFPE 8 /**< Arithmetic exception */ 25 #define SIGKILL 9 /**< Killed */ 26 #define SIGUSR1 10 /**< User-defined signal 1 */ 27 #define SIGSEGV 11 /**< Invalid memory reference */ 28 #define SIGUSR2 12 /**< User-defined signal 2 */ 29 #define SIGPIPE 13 /**< Broken pipe */ 30 #define SIGALRM 14 /**< Alarm clock */ 31 #define SIGTERM 15 /**< Terminated */ 32 /* 16 not used */ 33 #define SIGCHLD 17 /**< Child status changed */ 34 #define SIGCONT 18 /**< Continued */ 35 #define SIGSTOP 19 /**< Stop executing */ 36 #define SIGTSTP 20 /**< Stopped */ 37 #define SIGTTIN 21 /**< Stopped (read) */ 38 #define SIGTTOU 22 /**< Stopped (write) */ 39 #define SIGURG 23 /**< Urgent I/O condition */ 40 #define SIGXCPU 24 /**< CPU time limit exceeded */ 41 #define SIGXFSZ 25 /**< File size limit exceeded */ 42 #define SIGVTALRM 26 /**< Virtual timer expired */ 43 #define SIGPROF 27 /**< Profiling timer expired */ 44 /* 28 not used */ 45 #define SIGPOLL 29 /**< Pollable event occurred */ 46 /* 30 not used */ 47 #define SIGSYS 31 /**< Bad system call */ 48 49 #define SIGRTMIN 32 50 #define SIGRTMAX (SIGRTMIN + RTSIG_MAX) 51 #define _NSIG (SIGRTMAX + 1) 52 53 BUILD_ASSERT(RTSIG_MAX >= 0); 54 55 typedef struct { 56 unsigned long sig[DIV_ROUND_UP(_NSIG, BITS_PER_LONG)]; 57 } sigset_t; 58 59 #ifndef SIGEV_NONE 60 #define SIGEV_NONE 1 61 #endif 62 63 #ifndef SIGEV_SIGNAL 64 #define SIGEV_SIGNAL 2 65 #endif 66 67 #ifndef SIGEV_THREAD 68 #define SIGEV_THREAD 3 69 #endif 70 71 #ifndef SIG_BLOCK 72 #define SIG_BLOCK 0 73 #endif 74 #ifndef SIG_SETMASK 75 #define SIG_SETMASK 1 76 #endif 77 #ifndef SIG_UNBLOCK 78 #define SIG_UNBLOCK 2 79 #endif 80 81 #define SIG_DFL ((void *)0) 82 #define SIG_IGN ((void *)1) 83 #define SIG_ERR ((void *)-1) 84 85 #define SI_USER 1 86 #define SI_QUEUE 2 87 #define SI_TIMER 3 88 #define SI_ASYNCIO 4 89 #define SI_MESGQ 5 90 91 typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ 92 93 union sigval { 94 void *sival_ptr; 95 int sival_int; 96 }; 97 98 struct sigevent { 99 void (*sigev_notify_function)(union sigval val); 100 pthread_attr_t *sigev_notify_attributes; 101 union sigval sigev_value; 102 int sigev_notify; 103 int sigev_signo; 104 }; 105 106 typedef struct { 107 int si_signo; 108 int si_code; 109 union sigval si_value; 110 } siginfo_t; 111 112 struct sigaction { 113 void (*sa_handler)(int signno); 114 sigset_t sa_mask; 115 int sa_flags; 116 void (*sa_sigaction)(int signo, siginfo_t *info, void *context); 117 }; 118 119 typedef void (*sighandler_t)(int signo); 120 121 unsigned int alarm(unsigned int seconds); 122 int kill(pid_t pid, int sig); 123 int pause(void); 124 int raise(int signo); 125 TOOLCHAIN_IGNORE_WSHADOW_BEGIN; 126 int sigaction(int sig, const struct sigaction *ZRESTRICT act, struct sigaction *ZRESTRICT oact); 127 TOOLCHAIN_IGNORE_WSHADOW_END; 128 int sigpending(sigset_t *set); 129 int sigsuspend(const sigset_t *sigmask); 130 int sigwait(const sigset_t *ZRESTRICT set, int *ZRESTRICT signo); 131 char *strsignal(int signum); 132 int sigemptyset(sigset_t *set); 133 int sigfillset(sigset_t *set); 134 int sigaddset(sigset_t *set, int signo); 135 int sigdelset(sigset_t *set, int signo); 136 int sigismember(const sigset_t *set, int signo); 137 sighandler_t signal(int signo, sighandler_t handler); 138 int sigprocmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset); 139 140 int pthread_sigmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset); 141 142 #ifdef __cplusplus 143 } 144 #endif 145 146 #endif /* ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ */ 147