19#ifndef ZEPHYR_INCLUDE_POSIX_POSIX_SIGNAL_H_
20#define ZEPHYR_INCLUDE_POSIX_POSIX_SIGNAL_H_
22#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__)
24#include <zephyr/kernel/signal.h>
25#include <zephyr/toolchain.h>
26#include <zephyr/sys/util.h>
35#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
37#define SIG_HOLD ((void *)-2)
42#if defined(_POSIX_THREADS) || defined(__DOXYGEN__)
44#if !defined(_PTHREAD_T_DECLARED) && !defined(__pthread_t_defined)
45typedef unsigned int pthread_t;
46#define _PTHREAD_T_DECLARED
47#define __pthread_t_defined
56#if !defined(_UID_T_DECLARED) && !defined(__uid_t_defined)
58#define _UID_T_DECLARED
59#define __uid_t_defined
65#if __STDC_VERSION__ >= 201112L
68#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined)
73#define _TIMESPEC_DECLARED
74#define __timespec_defined
86#define SIGRTMIN (CONFIG_THREAD_CANCEL_SIGNAL_NUMBER + 2)
88#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
89BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= 0);
90BUILD_ASSERT((CONFIG_THREAD_CANCEL_SIGNAL_NUMBER + 2 +
91 CONFIG_POSIX_RTSIG_MAX) <= SIGNAL_SET_SIZE);
94#define SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX)
98#define SIGRTMAX SIGRTMIN
102#if !defined(_SIGSET_T_DECLARED) && !defined(__sigset_t_defined)
105 unsigned long sig[DIV_ROUND_UP(
SIGRTMAX, BITS_PER_LONG)];
107#define _SIGSET_T_DECLARED
108#define __sigset_t_defined
111#if !defined(_PID_T_DECLARED) && !defined(__pid_t_defined)
113#define _PID_T_DECLARED
114#define __pid_t_defined
117#if defined(_POSIX_THREADS) || defined(__DOXYGEN__)
120#if !defined(_PTHREAD_ATTR_T_DECLARED) && !defined(__pthread_attr_t_defined)
127#define _PTHREAD_ATTR_T_DECLARED
128#define __pthread_attr_t_defined
134#if !defined(_SIGVAL_DECLARED) && !defined(__sigval_defined)
140#define _SIGVAL_DECLARED
141#define __sigval_defined
149#if !defined(_SIGEVENT_DECLARED) && !defined(__sigevent_defined)
152#if defined(_POSIX_THREADS) || defined(__DOXYGEN__)
162#define _SIGEVENT_DECLARED
163#define __sigevent_defined
169#define SIGEV_SIGNAL 2
171#define SIGEV_THREAD 3
172#if defined(_GNU_SOURCE) || defined(__ZEPHYR__) || defined(__DOXYGEN__)
174#define SIGEV_THREAD_ID 4
182#if !defined(_SIGINFO_T_DECLARED) && !defined(__siginfo_t_defined)
186#if defined(_XOPEN_STREAMS) || defined(__DOXYGEN__)
194#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
199#define _SIGINFO_T_DECLARED
200#define __siginfo_t_defined
203#if !defined(_SIGACTION_DECLARED) && !defined(__sigaction_defined)
213#define _SIGACTION_DECLARED
214#define __sigaction_defined
224#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
226#define SA_NOCLDSTOP 0x00000001
228#define SA_ONSTACK 0x00000002
231#define SA_RESETHAND 0x00000004
233#define SA_RESTART 0x00000008
235#define SA_SIGINFO 0x00000010
236#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
238#define SA_NOCLDWAIT 0x00000020
241#define SA_NODEFER 0x00000040
243#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
246#define SS_ONSTACK 0x00000001
248#define SS_DISABLE 0x00000002
250#define MINSIGSTKSZ 4096
254#if !defined(_MCONTEXT_T_DECLARED) && !defined(__mcontext_t_defined)
258 unsigned long gregs[32];
261#define _MCONTEXT_T_DECLARED
262#define __mcontext_defined
266#if !defined(_STACK_T_DECLARED) && !defined(__stack_t_defined)
273#define _STACK_T_DECLARED
274#define __stack_t_defined
277#if !defined(_UCONTEXT_T_DECLARED) && !defined(__ucontext_t_defined)
285#define _UCONTEXT_T_DECLARED
286#define __ucontext_defined
293#if !defined(_SIGHANDLER_T_DECLARED) && !defined(__sighandler_t_defined)
296#define _SIGHANDLER_T_DECLARED
297#define __sighandler_t_defined
310#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
340#if defined(_POSIX_THREADS) || defined(__DOXYGEN__)
363TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_SHADOW);
374TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_SHADOW);
386#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
426#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
466#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
497#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
510#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
540#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
551 const struct timespec *ZRESTRICT timeout);
564#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
579#if !defined(SIGINT) || defined(__DOXYGEN__)
583#if !defined(SIGILL) || defined(__DOXYGEN__)
587#if !defined(SIGABRT) || defined(__DOXYGEN__)
591#if !defined(SIGFPE) || defined(__DOXYGEN__)
596#if !defined(SIGSEGV) || defined(__DOXYGEN__)
602#if !defined(SIGTERM) || defined(__DOXYGEN__)
622#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
645#define SEGV_MAPERR 18
646#define SEGV_ACCERR 19
653#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
660#define CLD_EXITED K_SI_CLD_EXITED
661#define CLD_KILLED K_SI_CLD_KILLED
662#define CLD_DUMPED K_SI_CLD_DUMPED
663#define CLD_TRAPPED K_SI_CLD_TRAPPED
664#define CLD_STOPPED K_SI_CLD_STOPPED
665#define CLD_CONTINUED K_SI_CLD_CONTINUED
667#if defined(_XOPEN_STREAMS) || defined(__DOXYGEN__)
int pid_t
Process ID type.
int sigqueue(pid_t pid, int sig, union sigval value)
Queue a signal and data to a process.
#define SIGRTMAX
Largest real-time signal number.
int sigtimedwait(const sigset_t *ZRESTRICT set, siginfo_t *ZRESTRICT info, const struct timespec *ZRESTRICT timeout)
Wait for a queued signal with a timeout.
int sigwaitinfo(const sigset_t *ZRESTRICT set, siginfo_t *ZRESTRICT info)
Wait for a queued signal (no timeout).
void psiginfo(const siginfo_t *info, const char *message)
Print a signal description with additional siginfo_t context.
void psignal(int sig, const char *message)
Print a signal description to stderr.
int sigignore(int sig)
Set a signal's disposition to SIG_IGN (XSI, obsolescent).
int sigdelset(sigset_t *set, int sig)
Delete a signal from a signal set.
int kill(pid_t pid, int sig)
Send a signal to a process or process group.
int sigemptyset(sigset_t *set)
Initialise a signal set to the empty set.
int siginterrupt(int sig, int flag)
Control whether a signal restarts or interrupts system calls (XSI, obsolescent).
int sigismember(const sigset_t *set, int sig)
Test whether a signal is a member of a signal set.
int sigsuspend(const sigset_t *set)
Wait for a signal, atomically replacing the process signal mask.
int sigprocmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset)
Examine and change the calling process's signal mask.
int sigpending(sigset_t *set)
Retrieve the set of pending signals.
int sigfillset(sigset_t *set)
Initialise a signal set to the full set (all signals).
int sigrelse(int sig)
Remove a signal from the process signal mask (XSI, obsolescent).
int sighold(int sig)
Add a signal to the calling process's signal mask (XSI, obsolescent).
int sigwait(const sigset_t *ZRESTRICT set, int *ZRESTRICT sig)
Wait for a signal from a set.
int sigpause(int sig)
Suspend execution until a signal is delivered (XSI, obsolescent).
int sigaddset(sigset_t *set, int sig)
Add a signal to a signal set.
sighandler_t sigset(int sig, sighandler_t disp)
Set the disposition of a signal, optionally blocking it first (XSI, obsolescent).
int pthread_sigmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset)
Examine and change blocked signals for the calling thread.
int pthread_kill(pthread_t thread, int sig)
Send a signal to a specific thread.
int killpg(pid_t pgrp, int sig)
Send a signal to a process group (XSI extension).
int sigaltstack(const stack_t *ZRESTRICT ss, stack_t *ZRESTRICT oss)
Set or get the alternate signal stack (XSI extension).
void(* sighandler_t)(int sig)
Function pointer type for a simple signal handler.
Machine-specific context saved when a signal is delivered.
unsigned long flags
Architecture-specific flags.
Signal action structure used with sigaction().
void(* sa_sigaction)(int sig, siginfo_t *info, void *context)
Extended handler (SA_SIGINFO set).
sigset_t sa_mask
Signals blocked during handler execution.
void(* sa_handler)(int sig)
Simple handler (SA_SIGINFO not set).
int sa_flags
Flags modifying signal behaviour (SA_* constants).
Structure describing how to notify about an asynchronous event.
void(* sigev_notify_function)(union sigval value)
Notification function.
pthread_attr_t * sigev_notify_attributes
Thread attributes for SIGEV_THREAD.
int sigev_signo
Signal number for SIGEV_SIGNAL notifications.
union sigval sigev_value
Value passed to notification function or signal.
int sigev_notify
Notification type: SIGEV_NONE, SIGEV_SIGNAL, SIGEV_THREAD.
pid_t sigev_notify_thread_id
Thread ID associated with SIGEV_THREAD_ID (Linux-compatible extension)
Information associated with a received signal.
int si_code
Signal code (reason the signal was generated).
uid_t si_uid
Real UID of the sending process.
int si_signo
Signal number.
pid_t si_pid
Sending process ID.
long si_band
Band event number for SIGPOLL (XSI streams).
int si_status
Exit value or signal (SIGCHLD).
void * si_addr
Address of the faulting instruction (SIGILL, SIGFPE, SIGSEGV, SIGBUS).
int si_errno
errno value associated with this signal, or 0.
Set of signals (bitmask).
Alternate signal stack descriptor.
void * ss_sp
Stack base address.
int ss_flags
SS_ONSTACK or SS_DISABLE.
size_t ss_size
Stack size in bytes.
Time value with nanosecond resolution.
long tv_nsec
Nanoseconds [0, 999999999].
User-space context saved and restored by getcontext()/setcontext().
stack_t uc_stack
Stack used by this context.
struct ucontext * uc_link
Context to resume when this one returns.
mcontext_t uc_mcontext
Machine-specific saved state.
sigset_t uc_sigmask
Signals blocked in this context.
POSIX time-of-day types and functions (<sys/time.h>)
Value passed to a signal handler or retrieved via siginfo_t.
void * sival_ptr
Pointer value.
int sival_int
Integer value.