about summary refs log tree commit diff
path: root/src/libstd/sys/unix/helper_signal.rs
blob: 17c8b21f8b3bcf51cc6861253fd19bd7b67fc91c (plain)
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
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(deprecated)]

use libc;
use os;

use sys::fs::FileDesc;

pub type signal = libc::c_int;

pub fn new() -> (signal, signal) {
    let os::Pipe { reader, writer } = unsafe { os::pipe().unwrap() };
    (reader, writer)
}

pub fn signal(fd: libc::c_int) {
    FileDesc::new(fd, false).write(&[0]).unwrap();
}

pub fn close(fd: libc::c_int) {
    let _fd = FileDesc::new(fd, true);
}