summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/ops/process.rs17
-rw-r--r--runtime/ops/runtime.rs1
-rw-r--r--runtime/ops/tty.rs3
-rw-r--r--runtime/permissions.rs1
4 files changed, 16 insertions, 6 deletions
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs
index a48cd122d..e5650e305 100644
--- a/runtime/ops/process.rs
+++ b/runtime/ops/process.rs
@@ -318,21 +318,26 @@ pub fn kill(pid: i32, signal: &str) -> Result<(), AnyError> {
} else if pid <= 0 {
Err(type_error("Invalid pid"))
} else {
+ // SAFETY: winapi call
let handle = unsafe { OpenProcess(PROCESS_TERMINATE, FALSE, pid as DWORD) };
if handle.is_null() {
+ // SAFETY: winapi call
let err = match unsafe { GetLastError() } {
ERROR_INVALID_PARAMETER => Error::from(NotFound), // Invalid `pid`.
errno => Error::from_raw_os_error(errno as i32),
};
Err(err.into())
} else {
- let is_terminated = unsafe { TerminateProcess(handle, 1) };
- unsafe { CloseHandle(handle) };
- match is_terminated {
- FALSE => Err(Error::last_os_error().into()),
- TRUE => Ok(()),
- _ => unreachable!(),
+ // SAFETY: winapi calls
+ unsafe {
+ let is_terminated = TerminateProcess(handle, 1);
+ CloseHandle(handle);
+ match is_terminated {
+ FALSE => Err(Error::last_os_error().into()),
+ TRUE => Ok(()),
+ _ => unreachable!(),
+ }
}
}
}
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs
index 31f9d2732..d12dfab96 100644
--- a/runtime/ops/runtime.rs
+++ b/runtime/ops/runtime.rs
@@ -51,6 +51,7 @@ pub fn ppid() -> i64 {
CreateToolhelp32Snapshot, Process32First, Process32Next, PROCESSENTRY32,
TH32CS_SNAPPROCESS,
};
+ // SAFETY: winapi calls
unsafe {
// Take a snapshot of system processes, one of which is ours
// and contains our parent's pid
diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs
index ab9553025..2018f954d 100644
--- a/runtime/ops/tty.rs
+++ b/runtime/ops/tty.rs
@@ -95,6 +95,7 @@ fn op_set_raw(state: &mut OpState, args: SetRawArgs) -> Result<(), AnyError> {
return Err(custom_error("ReferenceError", "null handle"));
}
let mut original_mode: DWORD = 0;
+ // SAFETY: winapi call
if unsafe { consoleapi::GetConsoleMode(handle, &mut original_mode) }
== FALSE
{
@@ -105,6 +106,7 @@ fn op_set_raw(state: &mut OpState, args: SetRawArgs) -> Result<(), AnyError> {
} else {
original_mode | RAW_MODE_MASK
};
+ // SAFETY: winapi call
if unsafe { consoleapi::SetConsoleMode(handle, new_mode) } == FALSE {
return Err(Error::last_os_error().into());
}
@@ -210,6 +212,7 @@ fn op_console_size(
use std::os::windows::io::AsRawHandle;
let handle = std_file.as_raw_handle();
+ // SAFETY: winapi calls
unsafe {
let mut bufinfo: winapi::um::wincon::CONSOLE_SCREEN_BUFFER_INFO =
std::mem::zeroed();
diff --git a/runtime/permissions.rs b/runtime/permissions.rs
index ab8baec89..de44989eb 100644
--- a/runtime/permissions.rs
+++ b/runtime/permissions.rs
@@ -1912,6 +1912,7 @@ fn permission_prompt(message: &str, name: &str) -> bool {
use winapi::um::winuser::MAPVK_VK_TO_VSC;
use winapi::um::winuser::VK_RETURN;
+ // SAFETY: winapi calls
unsafe {
let stdin = GetStdHandle(STD_INPUT_HANDLE);
// emulate an enter key press to clear any line buffered console characters