mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
4e1abb4f3a
To better reflect changes in error types in JS from #3662 this PR changes default error type used in ops from "ErrBox" to "OpError". "OpError" is a type that can be sent over to JSON; it has all information needed to construct error in JavaScript. That made "GetErrorKind" trait useless and so it was removed altogether. To provide compatibility with previous use of "ErrBox" an implementation of "From<ErrBox> for OpError" was added, however, it is an escape hatch and ops implementors should strive to use "OpError" directly.
17 lines
511 B
Rust
17 lines
511 B
Rust
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
use crate::op_error::OpError;
|
|
|
|
#[cfg(unix)]
|
|
pub fn kill(pid: i32, signo: i32) -> Result<(), OpError> {
|
|
use nix::sys::signal::{kill as unix_kill, Signal};
|
|
use nix::unistd::Pid;
|
|
let sig = Signal::from_c_int(signo)?;
|
|
unix_kill(Pid::from_raw(pid), Option::Some(sig)).map_err(OpError::from)
|
|
}
|
|
|
|
#[cfg(not(unix))]
|
|
pub fn kill(_pid: i32, _signal: i32) -> Result<(), OpError> {
|
|
// NOOP
|
|
// TODO: implement this for windows
|
|
Ok(())
|
|
}
|