Skip to main content

term_transcript/
utils.rs

1//! Misc utils.
2
3use std::io;
4
5#[cfg(not(windows))]
6pub(crate) fn is_recoverable_kill_error(err: &io::Error) -> bool {
7    matches!(err.kind(), io::ErrorKind::InvalidInput)
8}
9
10// As per `TerminateProcess` docs (`TerminateProcess` is used by `Child::kill()`),
11// the call will result in ERROR_ACCESS_DENIED if the process has already terminated.
12//
13// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminateprocess
14#[cfg(windows)]
15pub(crate) fn is_recoverable_kill_error(err: &io::Error) -> bool {
16    matches!(
17        err.kind(),
18        io::ErrorKind::InvalidInput | io::ErrorKind::PermissionDenied
19    )
20}