Skip to content
Snippets Groups Projects
Commit 43e95a9b authored by Michael Aaron Murphy's avatar Michael Aaron Murphy
Browse files

Implement kill() and killpg()

parent 5f9170d8
No related branches found
No related tags found
No related merge requests found
...@@ -115,6 +115,14 @@ pub fn getuid() -> uid_t { ...@@ -115,6 +115,14 @@ pub fn getuid() -> uid_t {
e(unsafe { syscall!(GETUID) }) 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 { 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 e(unsafe { syscall!(LINKAT, AT_FDCWD, path1, AT_FDCWD, path2, 0) }) as c_int
} }
......
...@@ -119,6 +119,14 @@ pub fn getuid() -> uid_t { ...@@ -119,6 +119,14 @@ pub fn getuid() -> uid_t {
e(syscall::getuid()) as pid_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 { pub fn link(path1: *const c_char, path2: *const c_char) -> c_int {
let path1 = unsafe { c_str(path1) }; let path1 = unsafe { c_str(path1) };
let path2 = unsafe { c_str(path2) }; let path2 = unsafe { c_str(path2) };
......
...@@ -27,12 +27,12 @@ pub type sigset_t = sys_sigset_t; ...@@ -27,12 +27,12 @@ pub type sigset_t = sys_sigset_t;
#[no_mangle] #[no_mangle]
pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int { pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int {
unimplemented!(); platform::kill(pid, sig)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn killpg(pgrp: pid_t, sig: c_int) -> c_int { pub extern "C" fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
unimplemented!(); platform::killpg(pgrp, sig)
} }
#[no_mangle] #[no_mangle]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment