[1] | 1 | #ifndef _SIGNAL_H |
---|
| 2 | #define _SIGNAL_H |
---|
| 3 | |
---|
| 4 | #include <stdint.h> |
---|
| 5 | #include <sys/types.h> |
---|
| 6 | |
---|
| 7 | /* START COPY FROM KERNEL */ |
---|
| 8 | #define SIG_DEFAULT 0L |
---|
| 9 | #define SIG_IGNORE 1L |
---|
| 10 | #define SIG_ERROR -1L |
---|
| 11 | |
---|
| 12 | #define SIGHUP 1 /* hangup */ |
---|
| 13 | #define SIGINT 2 /* interrupt */ |
---|
| 14 | #define SIGQUIT 3 /* quit */ |
---|
| 15 | #define SIGILL 4 /* illegal instruction (not reset when caught) */ |
---|
| 16 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ |
---|
| 17 | #define SIGIOT 6 /* IOT instruction */ |
---|
| 18 | #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ |
---|
| 19 | #define SIGEMT 7 /* EMT instruction */ |
---|
| 20 | #define SIGFPE 8 /* floating point exception */ |
---|
| 21 | #define SIGKILL 9 /* kill (cannot be caught or ignored) */ |
---|
| 22 | #define SIGBUS 10 /* bus error */ |
---|
| 23 | #define SIGSEGV 11 /* segmentation violation */ |
---|
| 24 | #define SIGSYS 12 /* bad argument to system call */ |
---|
| 25 | #define SIGPIPE 13 /* write on a pipe with no one to read it */ |
---|
| 26 | #define SIGALRM 14 /* alarm clock */ |
---|
| 27 | #define SIGTERM 15 /* software termination signal from kill */ |
---|
| 28 | #define SIGURG 16 /* urgent condition on IO channel */ |
---|
| 29 | #define SIGSTOP 17 /* sendable stop signal not from tty */ |
---|
| 30 | #define SIGTSTP 18 /* stop signal from tty */ |
---|
| 31 | #define SIGCONT 19 /* continue a stopped process */ |
---|
| 32 | #define SIGCHLD 20 /* to parent on child stop or exit */ |
---|
| 33 | #define SIGCLD 20 /* System V name for SIGCHLD */ |
---|
| 34 | #define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
---|
| 35 | #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
---|
| 36 | #define SIGIO 23 /* input/output possible signal */ |
---|
| 37 | #define SIGPOLL SIGIO /* System V name for SIGIO */ |
---|
| 38 | #define SIGXCPU 24 /* exceeded CPU time limit */ |
---|
| 39 | #define SIGXFSZ 25 /* exceeded file size limit */ |
---|
| 40 | #define SIGVTALRM 26 /* virtual time alarm */ |
---|
| 41 | #define SIGPROF 27 /* profiling time alarm */ |
---|
| 42 | #define SIGWINCH 28 /* window changed */ |
---|
| 43 | #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ |
---|
| 44 | #define SIGUSR1 30 /* user defined signal 1 */ |
---|
| 45 | #define SIGUSR2 31 /* user defined signal 2 */ |
---|
| 46 | #define NSIG 32 /* signal 0 implied */ |
---|
| 47 | |
---|
| 48 | typedef uint32_t sigval_t; |
---|
| 49 | typedef uint32_t sigset_t; |
---|
| 50 | |
---|
| 51 | typedef struct siginfo_s |
---|
| 52 | { |
---|
| 53 | int si_signo; /* Signal number */ |
---|
| 54 | int si_errno; /* An errno value */ |
---|
| 55 | int si_code; /* Signal code */ |
---|
| 56 | pid_t si_pid; /* Sending process ID */ |
---|
| 57 | uid_t si_uid; /* Real user ID of sending process */ |
---|
| 58 | int si_status; /* Exit value or signal */ |
---|
| 59 | clock_t si_utime; /* User time consumed */ |
---|
| 60 | clock_t si_stime; /* System time consumed */ |
---|
| 61 | sigval_t si_value; /* Signal value */ |
---|
| 62 | int si_int; /* POSIX.1b signal */ |
---|
| 63 | void *si_ptr; /* POSIX.1b signal */ |
---|
| 64 | void *si_addr; /* Memory location which caused fault */ |
---|
| 65 | int si_band; /* Band event */ |
---|
| 66 | int si_fd; /* File descriptor */ |
---|
| 67 | }siginfo_t; |
---|
| 68 | |
---|
| 69 | struct sigaction_s |
---|
| 70 | { |
---|
| 71 | sigset_t sa_mask; |
---|
| 72 | uint32_t sa_flags; |
---|
| 73 | union |
---|
| 74 | { |
---|
| 75 | void (*sa_handler)(int); |
---|
| 76 | void (*sa_sigaction)(int, siginfo_t *, void *); |
---|
| 77 | }; |
---|
| 78 | }; |
---|
| 79 | /* END COPY FROM KERNEL */ |
---|
| 80 | |
---|
| 81 | typedef void (*__sighandler_t)(int); |
---|
| 82 | |
---|
| 83 | #ifdef _BSD_SOURCE |
---|
| 84 | typedef sighandler_t sig_t; |
---|
| 85 | #endif |
---|
| 86 | |
---|
| 87 | #ifdef _GNU_SOURCE |
---|
| 88 | typedef __sighandler_t sighandler_t; |
---|
| 89 | #endif |
---|
| 90 | |
---|
| 91 | #define SIG_DFL ((void*)SIG_DEFAULT) /* default signal handling */ |
---|
| 92 | #define SIG_IGN ((void*)SIG_IGNORE) /* ignore signal */ |
---|
| 93 | #define SIG_ERR ((void*)SIG_ERROR) /* error return from signal */ |
---|
| 94 | |
---|
| 95 | void* signal(int sig, void (*func)(int)); |
---|
| 96 | |
---|
| 97 | int kill(pid_t pid, int sig); |
---|
| 98 | int raise(int sig); |
---|
| 99 | |
---|
| 100 | #endif /* _SIGNAL_H_ */ |
---|