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 2015 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 typedef struct sigfd_wake_list { 79 list_node_t sigfd_wl_lst; 80 void *sigfd_wl_state; 81 } sigfd_wake_list_t; 82 83 /* 84 * This holds the proc_t state for a process which is using signalfd. 85 */ 86 typedef struct sigfd_proc_state { 87 void (*sigfd_pollwake_cb)(void *, int); 88 list_t sigfd_list; 89 } sigfd_proc_state_t; 90 91 92 extern void (*sigfd_exit_helper)(); 93 94 #endif /* _KERNEL */ 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 #endif /* _SYS_SIGNALFD_H */ 101