2020-01-24 08:15:31 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-02-23 14:51:29 -05:00
|
|
|
use crate::op_error::OpError;
|
2019-04-21 21:26:56 -04:00
|
|
|
|
|
|
|
#[cfg(unix)]
|
2020-02-23 14:51:29 -05:00
|
|
|
pub fn kill(pid: i32, signo: i32) -> Result<(), OpError> {
|
2019-07-10 18:53:48 -04:00
|
|
|
use nix::sys::signal::{kill as unix_kill, Signal};
|
|
|
|
use nix::unistd::Pid;
|
2020-04-08 14:29:42 -04:00
|
|
|
use std::convert::TryFrom;
|
|
|
|
let sig = Signal::try_from(signo)?;
|
2020-02-23 14:51:29 -05:00
|
|
|
unix_kill(Pid::from_raw(pid), Option::Some(sig)).map_err(OpError::from)
|
2019-04-21 21:26:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(unix))]
|
2020-02-23 14:51:29 -05:00
|
|
|
pub fn kill(_pid: i32, _signal: i32) -> Result<(), OpError> {
|
2019-04-21 21:26:56 -04:00
|
|
|
// TODO: implement this for windows
|
|
|
|
Ok(())
|
|
|
|
}
|