summaryrefslogtreecommitdiff
path: root/cli/signal.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-12-13 19:45:53 +0100
committerGitHub <noreply@github.com>2020-12-13 19:45:53 +0100
commit2e74f164b6dcf0ecbf8dd38fba9fae550d784bd0 (patch)
tree61abe8e09d5331ace5d9de529f0e2737a8e05dbb /cli/signal.rs
parent84ef9bd21fb48fb6b5fbc8dafc3de9f361bade3b (diff)
refactor: deno_runtime crate (#8640)
This commit moves Deno JS runtime, ops, permissions and inspector implementation to new "deno_runtime" crate located in "runtime/" directory. Details in "runtime/README.md". Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/signal.rs')
-rw-r--r--cli/signal.rs62
1 files changed, 0 insertions, 62 deletions
diff --git a/cli/signal.rs b/cli/signal.rs
deleted file mode 100644
index b597714f4..000000000
--- a/cli/signal.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-use deno_core::error::AnyError;
-
-#[cfg(not(unix))]
-use deno_core::error::last_os_error;
-#[cfg(not(unix))]
-use deno_core::error::type_error;
-
-#[cfg(not(unix))]
-const SIGINT: i32 = 2;
-#[cfg(not(unix))]
-const SIGKILL: i32 = 9;
-#[cfg(not(unix))]
-const SIGTERM: i32 = 15;
-
-#[cfg(not(unix))]
-use winapi::{
- shared::minwindef::DWORD,
- um::{
- handleapi::CloseHandle,
- processthreadsapi::{OpenProcess, TerminateProcess},
- winnt::PROCESS_TERMINATE,
- },
-};
-
-#[cfg(unix)]
-pub fn kill(pid: i32, signo: i32) -> Result<(), AnyError> {
- use nix::sys::signal::{kill as unix_kill, Signal};
- use nix::unistd::Pid;
- use std::convert::TryFrom;
- let sig = Signal::try_from(signo)?;
- unix_kill(Pid::from_raw(pid), Option::Some(sig)).map_err(AnyError::from)
-}
-
-#[cfg(not(unix))]
-pub fn kill(pid: i32, signal: i32) -> Result<(), AnyError> {
- match signal {
- SIGINT | SIGKILL | SIGTERM => {
- if pid <= 0 {
- return Err(type_error("unsupported pid"));
- }
- unsafe {
- let handle = OpenProcess(PROCESS_TERMINATE, 0, pid as DWORD);
- if handle.is_null() {
- return Err(last_os_error());
- }
- if TerminateProcess(handle, 1) == 0 {
- CloseHandle(handle);
- return Err(last_os_error());
- }
- if CloseHandle(handle) == 0 {
- return Err(last_os_error());
- }
- }
- }
- _ => {
- return Err(type_error("unsupported signal"));
- }
- }
- Ok(())
-}