sig/
ffi.rs

1// @adjivas - github.com/adjivas. See the LICENSE
2// file at the top-level directory of this distribution and at
3// https://github.com/adjivas/sig
4//
5// This file may not be copied, modified, or distributed
6// except according to those terms.
7
8pub use libc::{pid_t, c_int, getpid, kill};
9
10#[allow(non_snake_case)]
11#[cfg(unix)]
12#[cfg(not(target_os = "macos"))]
13pub mod Sig {
14    use libc::{self, c_int};
15
16    pub const HUP    : c_int = libc::SIGHUP;    // Hangup (POSIX).
17    pub const INT    : c_int = libc::SIGINT;    // Interrupt (ANSI).
18    pub const QUIT   : c_int = libc::SIGQUIT;   // Quit (POSIX).
19    pub const ILL    : c_int = libc::SIGILL;    // Illegal instruction (ANSI).
20    pub const TRAP   : c_int = libc::SIGTRAP;   // Trace trap (POSIX).
21    pub const ABRT   : c_int = libc::SIGABRT;   // Abort (POSIX).
22    pub const IOT    : c_int = libc::SIGIOT;    // IOT trap (4.2 BSD).
23    pub const BUS    : c_int = libc::SIGBUS;    // BUS error (4.2 BSD).
24    pub const FPE    : c_int = libc::SIGFPE;
25    pub const KILL   : c_int = libc::SIGKILL;   // Kill unblockable (POSIX).
26    pub const USR1   : c_int = libc::SIGUSR1;   // User-defined signal 1 (POSIX).
27    pub const SEGV   : c_int = libc::SIGSEGV;   // Segmentation violation (ANSI).
28    pub const USR2   : c_int = libc::SIGUSR2;   // User-defined signal 2 (POSIX).
29    pub const PIPE   : c_int = libc::SIGPIPE;   // Broken pipe (POSIX).
30    pub const ALRM   : c_int = libc::SIGALRM;   // Alarm clock (POSIX).
31    pub const TERM   : c_int = libc::SIGTERM;   // Termination (ANSI).
32    pub const STKFLT : c_int = libc::SIGSTKFLT; // Stack fault.
33    pub const CHLD   : c_int = libc::SIGCHLD;   // Child status has changed (POSIX).
34    pub const CONT   : c_int = libc::SIGCONT;   // Continue (POSIX).
35    pub const STOP   : c_int = libc::SIGSTOP;   // Stop unblockable (POSIX).
36    pub const TSTP   : c_int = libc::SIGTSTP;   // Keyboard stop (POSIX).
37    pub const TTIN   : c_int = libc::SIGTTIN;   // Background read from tty (POSIX).
38    pub const TTOU   : c_int = libc::SIGTTOU;   // Background write to tttty (POSIX).
39    pub const URG    : c_int = libc::SIGURG;    // Urgent condition on socket (4.2 BSD).
40    pub const XCPU   : c_int = libc::SIGXCPU;   // CPU limit exceeded (4.2 BSD).
41    pub const PROF   : c_int = libc::SIGPROF;   // Profiling alarm clock (4.2 BSD).
42    pub const WINCH  : c_int = libc::SIGWINCH;  // Window size change (4.3 BSD Sun).
43    pub const POLL   : c_int = libc::SIGPOLL;   // Pollable event occured (System V).
44    pub const PWR    : c_int = libc::SIGPWR;    // Power failure restart (System V).
45    pub const SYS    : c_int = libc::SIGSYS;    // Bad system call.
46}
47
48#[allow(non_snake_case)]
49#[cfg(target_os = "macos")]
50pub mod Sig {
51    use libc::{self, c_int};
52
53    pub const HUP    : c_int = libc::SIGHUP;    // Hangup (POSIX).
54    pub const INT    : c_int = libc::SIGINT;    // Interrupt (ANSI).
55    pub const QUIT   : c_int = libc::SIGQUIT;   // Quit (POSIX).
56    pub const ILL    : c_int = libc::SIGILL;    // Illegal instruction (ANSI).
57    pub const TRAP   : c_int = libc::SIGTRAP;   // Trace trap (POSIX).
58    pub const ABRT   : c_int = libc::SIGABRT;   // Abort (POSIX).
59    pub const IOT    : c_int = libc::SIGIOT;    // IOT trap (4.2 BSD).
60    pub const BUS    : c_int = libc::SIGBUS;    // BUS error (4.2 BSD).
61    pub const FPE    : c_int = libc::SIGFPE;
62    pub const KILL   : c_int = libc::SIGKILL;   // Kill unblockable (POSIX).
63    pub const USR1   : c_int = libc::SIGUSR1;   // User-defined signal 1 (POSIX).
64    pub const SEGV   : c_int = libc::SIGSEGV;   // Segmentation violation (ANSI).
65    pub const USR2   : c_int = libc::SIGUSR2;   // User-defined signal 2 (POSIX).
66    pub const PIPE   : c_int = libc::SIGPIPE;   // Broken pipe (POSIX).
67    pub const ALRM   : c_int = libc::SIGALRM;   // Alarm clock (POSIX).
68    pub const TERM   : c_int = libc::SIGTERM;   // Termination (ANSI).
69    pub const CHLD   : c_int = libc::SIGCHLD;   // Child status has changed (POSIX).
70    pub const CONT   : c_int = libc::SIGCONT;   // Continue (POSIX).
71    pub const STOP   : c_int = libc::SIGSTOP;   // Stop unblockable (POSIX).
72    pub const TSTP   : c_int = libc::SIGTSTP;   // Keyboard stop (POSIX).
73    pub const TTIN   : c_int = libc::SIGTTIN;   // Background read from tty (POSIX).
74    pub const TTOU   : c_int = libc::SIGTTOU;   // Background write to tttty (POSIX).
75    pub const URG    : c_int = libc::SIGURG;    // Urgent condition on socket (4.2 BSD).
76    pub const XCPU   : c_int = libc::SIGXCPU;   // CPU limit exceeded (4.2 BSD).
77    pub const PROF   : c_int = libc::SIGPROF;   // Profiling alarm clock (4.2 BSD).
78    pub const WINCH  : c_int = libc::SIGWINCH;  // Window size change (4.3 BSD Sun).
79    pub const SYS    : c_int = libc::SIGSYS;    // Bad system call.
80}