Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
signal.h
Go to the documentation of this file.
1 
4 #ifndef __SIGNAL_H__
5 #define __SIGNAL_H__
6 
7 #include <sys/types.h>
8 
9 struct timespec;
10 
11 #define SIGUSR1 10
12 #define SIGUSR2 12
13 #define SIGPOLL 29
14 #define SIGSTOP 19
15 #define SIGCONT 18
16 #define SIGKILL 9
17 #define SIGNAL_CNT 6
18 
19 /* The rest of the POSIX set. Tenok delivers none of them, the numbers are
20  * named so that a program written for a POSIX system compiles
21  */
22 #define SIGHUP 1
23 #define SIGINT 2
24 #define SIGQUIT 3
25 #define SIGILL 4
26 #define SIGTRAP 5
27 #define SIGABRT 6
28 #define SIGBUS 7
29 #define SIGFPE 8
30 #define SIGSEGV 11
31 #define SIGPIPE 13
32 #define SIGALRM 14
33 #define SIGTERM 15
34 #define SIGCHLD 17
35 #define SIGTSTP 20
36 #define SIGTTIN 21
37 #define SIGTTOU 22
38 #define SIGURG 23
39 #define SIGXCPU 24
40 #define SIGXFSZ 25
41 #define SIGVTALRM 26
42 #define SIGPROF 27
43 #define SIGWINCH 28
44 #define SIGSYS 31
45 
46 #define NSIG 32
47 
48 #define SIG_DFL ((void (*)(int)) 0)
49 #define SIG_IGN ((void (*)(int)) 1)
50 #define SIG_ERR ((void (*)(int)) - 1)
51 
52 #define SIG_BLOCK 0
53 #define SIG_UNBLOCK 1
54 #define SIG_SETMASK 2
55 
56 #define SA_SIGINFO 0x2
57 #define SA_RESTART 0x10000000
58 #define SA_NOCLDSTOP 0x00000001
59 
60 #define SIGEV_NONE 1
61 #define SIGEV_SIGNAL 2
62 
63 typedef uint32_t sigset_t;
64 
65 union sigval {
66  int sival_int;
67  void *sival_ptr;
68 };
69 
70 typedef struct {
71  int si_signo;
72  int si_code;
73  union sigval si_value;
74 } siginfo_t;
75 
76 struct sigaction {
77  union {
78  void (*sa_handler)(int);
79  void (*sa_sigaction)(int, siginfo_t *, void *);
80  };
81  sigset_t sa_mask;
82  int sa_flags;
83 };
84 
85 typedef void (*sa_handler_t)(int);
86 typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
87 
88 struct sigevent {
89  int sigev_notify;
90  int sigev_signo;
91  union sigval sigev_value;
92  void (*sigev_notify_function)(union sigval);
93  void *sigev_notify_attributes;
94  pid_t sigev_notify_thread_id;
95 };
96 
103 int sigemptyset(sigset_t *set);
104 
110 int sigfillset(sigset_t *set);
111 
118 int sigaddset(sigset_t *set, int signum);
119 
126 int sigdelset(sigset_t *set, int signum);
127 
134 int sigismember(const sigset_t *set, int signum);
135 
142 sa_handler_t signal(int signum, sa_handler_t handler);
143 
152 int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
153 
160 int sigsuspend(const sigset_t *mask);
161 
169 int sigaction(int signum,
170  const struct sigaction *act,
171  struct sigaction *oldact);
172 
180 int sigwait(const sigset_t *set, int *sig);
181 
188 int sigwaitinfo(const sigset_t *set, siginfo_t *info);
189 
197 int sigtimedwait(const sigset_t *set,
198  siginfo_t *info,
199  const struct timespec *timeout);
200 
207 int pause(void);
208 
215 int kill(pid_t pid, int sig);
216 
222 int raise(int sig);
223 
224 #endif
Definition: signal.h:76
Definition: signal.h:88
Definition: signal.h:70
Definition: time.h:16
int sigwaitinfo(const sigset_t *set, siginfo_t *info)
Wait for a signal and return siginfo.
Definition: signal.c:146
sa_handler_t signal(int signum, sa_handler_t handler)
Set up a handler for a signal, the older way POSIX keeps.
Definition: signal_posix.c:6
int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
Read and replace the set of signals the thread blocks. Tenok blocks none, so the set is accepted and ...
Definition: signal_posix.c:20
int kill(pid_t pid, int sig)
Send a signal to a task.
Definition: signal.c:189
int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
Wait for a signal with timeout.
Definition: signal.c:158
int pause(void)
To cause the calling task (or thread) to sleep until a signal is delivered that either terminate the ...
Definition: signal.c:165
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
Set up a signal for the task to catch.
Definition: signal.c:126
int sigemptyset(sigset_t *set)
Initialize the signal set given by set to empty, with all signals excluded from the set.
Definition: signal.c:63
int sigismember(const sigset_t *set, int signum)
Test whether sugnum is a member of the set.
Definition: signal.c:107
int sigfillset(sigset_t *set)
Initialize the signal set to full, including all signals.
Definition: signal.c:72
int sigdelset(sigset_t *set, int signum)
Delete a signal from the set.
Definition: signal.c:94
int sigwait(const sigset_t *set, int *sig)
Suspend execution of the calling task until one of the signals specified in the signal set becomes pe...
Definition: signal.c:136
int sigaddset(sigset_t *set, int signum)
Add a signal into the set.
Definition: signal.c:81
int sigsuspend(const sigset_t *mask)
Wait for a signal that is not in the mask. Tenok blocks no signal, so there is never one to wait for ...
Definition: signal_posix.c:29
Definition: signal.h:65