Skip to content

Commit

Permalink
Polish.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jan 31, 2025
1 parent ead971b commit 6cb9ad3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 0 additions & 2 deletions crates/action-pipeline/src/action_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ pub async fn run_action(
)
.await;

dbg!(&result);

emitter
.emit(Event::TaskRan {
error: extract_error(&result),
Expand Down
10 changes: 7 additions & 3 deletions crates/process/src/shared_child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct SharedChild {
inner: Arc<Mutex<Child>>,
pid: u32,
#[cfg(windows)]
handle: std::os::windows::io::RawHandle,
handle: RawHandle,
}

impl SharedChild {
Expand All @@ -26,8 +26,8 @@ impl SharedChild {
pub fn new(child: Child) -> Self {
Self {
pid: child.id().unwrap(),
handle: RawHandle(child.raw_handle().unwrap()),
inner: Arc::new(Mutex::new(child)),
handle: child.raw_handle().unwrap(),
}
}

Expand Down Expand Up @@ -55,7 +55,11 @@ impl SharedChild {
Ok(())
}

pub async fn kill_with_signal(&self, signal: SignalType) -> io::Result<()> {
pub async fn kill_with_signal(
&self,
#[cfg(unix)] signal: SignalType,
#[cfg(windows)] _signal: SignalType,
) -> io::Result<()> {
// https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/unix/process/process_unix.rs#L940
#[cfg(unix)]
{
Expand Down
12 changes: 8 additions & 4 deletions crates/process/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ mod unix {
if result != 0 {
let error = io::Error::last_os_error();

dbg!(result, &error);

// "No such process" error, so it may have been killed already
// https://man7.org/linux/man-pages/man3/errno.3.html
if error.raw_os_error().is_some_and(|code| code == 3) {
Expand Down Expand Up @@ -87,6 +85,12 @@ mod windows {
fn TerminateProcess(hProcess: *mut c_void, uExitCode: c_uint) -> c_int;
}

#[derive(Clone)]
struct RawHandle(*mut c_void);

unsafe impl Send for RawHandle {}
unsafe impl Sync for RawHandle {}

pub async fn wait_for_signal(sender: Sender<SignalType>) {
use tokio::signal::windows;

Expand Down Expand Up @@ -117,8 +121,8 @@ mod windows {
};
}

pub fn terminate(handle: *mut c_void) -> io::Result<()> {
if unsafe { TerminateProcess(handle, 1) } == 0 {
pub fn terminate(handle: RawHandle) -> io::Result<()> {
if unsafe { TerminateProcess(handle.0, 1) } == 0 {
Err(io::Error::last_os_error())
} else {
Ok(())
Expand Down

0 comments on commit 6cb9ad3

Please sign in to comment.