]> git.proxmox.com Git - rustc.git/blob - src/libstd/sys/unix/helper_signal.rs
Merge tag 'upstream-tar/1.0.0_0alpha'
[rustc.git] / src / libstd / sys / unix / helper_signal.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use libc;
12 use os;
13
14 use sys::fs::FileDesc;
15
16 pub type signal = libc::c_int;
17
18 pub fn new() -> (signal, signal) {
19 let os::Pipe { reader, writer } = unsafe { os::pipe().unwrap() };
20 (reader, writer)
21 }
22
23 pub fn signal(fd: libc::c_int) {
24 FileDesc::new(fd, false).write(&[0]).ok().unwrap();
25 }
26
27 pub fn close(fd: libc::c_int) {
28 let _fd = FileDesc::new(fd, true);
29 }