Merge pull request #108 from mmstick/kill

Implement kill() and killpg()
This commit is contained in:
Jeremy Soller
2018-03-25 18:56:09 -06:00
committed by GitHub
3 changed files with 18 additions and 2 deletions
+8
View File
@@ -115,6 +115,14 @@ pub fn getuid() -> uid_t {
e(unsafe { syscall!(GETUID) })
}
pub fn kill(pid: pid_t, sig: c_int) -> c_int {
e(unsafe { syscall!(KILL, pid, sig) }) as c_int
}
pub fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
e(unsafe { syscall!(KILL, -(pgrp as isize) as pid_t, sig) }) as c_int
}
pub fn link(path1: *const c_char, path2: *const c_char) -> c_int {
e(unsafe { syscall!(LINKAT, AT_FDCWD, path1, AT_FDCWD, path2, 0) }) as c_int
}
+8
View File
@@ -119,6 +119,14 @@ pub fn getuid() -> uid_t {
e(syscall::getuid()) as pid_t
}
pub fn kill(pid: pid_t, sig: c_int) -> c_int {
e(syscall::kill(pid, sig as usize)) as c_int
}
pub fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
e(syscall::kill(-(pgrp as isize) as pid_t, sig as usize)) as c_int
}
pub fn link(path1: *const c_char, path2: *const c_char) -> c_int {
let path1 = unsafe { c_str(path1) };
let path2 = unsafe { c_str(path2) };
+2 -2
View File
@@ -27,12 +27,12 @@ pub type sigset_t = sys_sigset_t;
#[no_mangle]
pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int {
unimplemented!();
platform::kill(pid, sig)
}
#[no_mangle]
pub extern "C" fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
unimplemented!();
platform::killpg(pgrp, sig)
}
#[no_mangle]