xref: /illumos-gate/usr/src/uts/common/sys/signalfd.h (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2016 Joyent, Inc.
14  */
15 
16 /*
17  * Header file to support the signalfd facility. Note that this facility
18  * is designed to be binary compatible with the Linux signalfd facility, modulo
19  * the signals themselves; values for constants here should therefore exactly
20  * match those found in Linux, and this facility shouldn't be extended
21  * independently of Linux.
22  */
23 
24 #ifndef _SYS_SIGNALFD_H
25 #define	_SYS_SIGNALFD_H
26 
27 #include <sys/types.h>
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * To assure binary compatibility with Linux, these values are fixed at their
35  * Linux equivalents, not their native ones.
36  */
37 #define	SFD_CLOEXEC		02000000		/* LX_O_CLOEXEC */
38 #define	SFD_NONBLOCK		04000			/* LX_O_NONBLOCK */
39 
40 /*
41  * These ioctl values are specific to the native implementation; applications
42  * shouldn't be using them directly, and they should therefore be safe to
43  * change without breaking apps.
44  */
45 #define	SIGNALFDIOC		(('s' << 24) | ('f' << 16) | ('d' << 8))
46 #define	SIGNALFDIOC_MASK	(SIGNALFDIOC | 1)	/* set mask */
47 
48 typedef struct signalfd_siginfo {
49 	uint32_t ssi_signo;	/* signal from signal.h */
50 	int32_t  ssi_errno;	/* error from errno.h */
51 	int32_t  ssi_code;	/* signal code */
52 	uint32_t ssi_pid;	/* PID of sender */
53 	uint32_t ssi_uid;	/* real UID of sender */
54 	int32_t  ssi_fd;	/* File descriptor (SIGIO) */
55 	uint32_t ssi_tid;	/* unused */
56 	uint32_t ssi_band;	/* band event (SIGIO) */
57 	uint32_t ssi_overrun;	/* unused */
58 	uint32_t ssi_trapno;	/* trap number that caused signal */
59 	int32_t  ssi_status;	/* exit status or signal (SIGCHLD) */
60 	int32_t  ssi_int;	/* unused */
61 	uint64_t ssi_ptr;	/* unused */
62 	uint64_t ssi_utime;	/* user CPU time consumed (SIGCHLD) */
63 	uint64_t ssi_stime;	/* system CPU time consumed (SIGCHLD) */
64 	uint64_t ssi_addr;	/* address that generated signal */
65 	uint8_t  ssi_pad[48];	/* Pad size to 128 bytes to allow for */
66 				/* additional fields in the future. */
67 } signalfd_siginfo_t;
68 
69 #ifndef _KERNEL
70 
71 extern int signalfd(int, const sigset_t *, int);
72 
73 #else
74 
75 #define	SIGNALFDMNRN_SIGNALFD	0
76 #define	SIGNALFDMNRN_CLONE	1
77 
78 /*
79  * This holds the proc_t state for a process which is using signalfd.
80  * Its presence and contents are protected by p_lock.
81  */
82 typedef struct sigfd_proc_state {
83 	void (*sigfd_pollwake_cb)(void *, int);
84 	list_t sigfd_list;
85 } sigfd_proc_state_t;
86 
87 
88 extern void (*sigfd_exit_helper)();
89 
90 #endif /* _KERNEL */
91 
92 #ifdef	__cplusplus
93 }
94 #endif
95 
96 #endif	/* _SYS_SIGNALFD_H */
97