1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// @adjivas - github.com/adjivas. See the LICENSE
// file at the top-level directory of this distribution and at
// https://github.com/adjivas/sig
//
// This file may not be copied, modified, or distributed
// except according to those terms.

/// The `getpid` macro returns the PID of
/// program.

#[macro_export]
macro_rules! getpid {
  () => ({
    unsafe { $crate::ffi::getpid() }
  });
}

/// The `signal` macro receives a signal to
/// a PID program.

#[macro_export]
macro_rules! signal {
    ($sig: expr, $fnc: expr) => ({
        unsafe {
            $crate::set_signal_handler (
                $sig as $crate::ffi::c_int,
                $fnc
            )
        }
    });
}

/// The `signal` macro sends a signal to
/// a PID program.

#[macro_export]
macro_rules! kill {
    ($pid: expr) => ({
        kill!($pid, sig::ffi::Sig::KILL)
    });
    ($pid: expr, $sig: expr) => ({
        match unsafe {
            sig::ffi::kill (
                $pid as $crate::ffi::pid_t,
                $sig as $crate::ffi::c_int,
            )
        } {
            -1 => true,
            _ => false,
        }
    });
}