xref: /plan9-contrib/sys/include/ape/signal.h (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1 #ifndef __SIGNAL_H
2 #define __SIGNAL_H
3 #pragma lib "/$M/lib/ape/libap.a"
4 
5 typedef int sig_atomic_t;
6 
7 /*
8  * We don't give arg types for signal handlers, in spite of ANSI requirement
9  * that it be 'int' (the signal number), because some programs need an
10  * additional context argument.  So the real type of signal handlers is
11  *      void handler(int sig, char *, struct Ureg *)
12  * where the char * is the Plan 9 message and Ureg is defined in <ureg.h>
13  */
14 #define SIG_DFL ((void (*)())0)
15 #define SIG_ERR ((void (*)())-1)
16 #define SIG_IGN ((void (*)())1)
17 
18 #define	SIGHUP	1	/* hangup */
19 #define	SIGINT	2	/* interrupt */
20 #define	SIGQUIT	3	/* quit */
21 #define	SIGILL	4	/* illegal instruction (not reset when caught)*/
22 #define SIGABRT 5	/* used by abort */
23 #define	SIGFPE	6	/* floating point exception */
24 #define	SIGKILL	7	/* kill (cannot be caught or ignored) */
25 #define	SIGSEGV	8	/* segmentation violation */
26 #define	SIGPIPE	9	/* write on a pipe with no one to read it */
27 #define	SIGALRM	10	/* alarm clock */
28 #define	SIGTERM	11	/* software termination signal from kill */
29 #define	SIGUSR1	12	/* user defined signal 1 */
30 #define	SIGUSR2	13	/* user defined signal 2 */
31 
32 /* The following symbols must be defined, but the signals needn't be supported */
33 #define SIGCHLD	14	/* child process terminated or stopped */
34 #define SIGCONT 15	/* continue if stopped */
35 #define SIGSTOP 16	/* stop */
36 #define SIGTSTP	17	/* interactive stop */
37 #define SIGTTIN	18	/* read from ctl tty by member of background */
38 #define SIGTTOU	19	/* write to ctl tty by member of background */
39 
40 #ifdef _BSD_EXTENSION
41 #define NSIG 20
42 #endif
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 extern void (*signal(int, void (*)()))();
49 extern int raise(int);
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 
55 #ifdef _POSIX_SOURCE
56 
57 typedef long sigset_t;
58 struct sigaction {
59 	void		(*sa_handler)();
60 	sigset_t	sa_mask;
61 	int		sa_flags;
62 };
63 /* values for sa_flags */
64 #define SA_NOCLDSTOP	1
65 
66 /* first argument to sigprocmask */
67 #define SIG_BLOCK	1
68 #define SIG_UNBLOCK	2
69 #define SIG_SETMASK	3
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
75 #ifdef __TYPES_H
76 extern int kill(pid_t, int);
77 #endif
78 extern int sigemptyset(sigset_t *);
79 extern int sigfillset(sigset_t *);
80 extern int sigaddset(sigset_t *, int);
81 extern int sigdelset(sigset_t *, int);
82 extern int sigismember(const sigset_t *, int);
83 extern int sigaction(int, const struct sigaction *, struct sigaction *);
84 extern int sigprocmask(int, sigset_t *, sigset_t *);
85 extern int sigpending(sigset_t *);
86 extern int sigsuspend(const sigset_t *);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* _POSIX_SOURCE */
93 
94 #endif /* __SIGNAL_H */
95