From 64ddcb3bf2aed84256fe8261a0b05e1831720463 Mon Sep 17 00:00:00 2001 From: Vadim Khitrin Date: Sat, 8 Mar 2025 00:43:13 +0200 Subject: [PATCH] fix: Support Spawning Processes on macOS Allow using pipe on macOS when attempting to spawn a process. --- src/process.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/process.rs b/src/process.rs index efbfdd10..d473ae66 100644 --- a/src/process.rs +++ b/src/process.rs @@ -23,15 +23,25 @@ async fn read_from_pipe(read: OwnedFd) -> Option { /// Performs a double fork with setsid to spawn and detach a command. pub async fn spawn(mut command: Command) -> Option { + // NOTE: Windows platform is not supported command .stdin(Stdio::null()) .stdout(Stdio::null()) .stderr(Stdio::null()); + // Handle Linux + #[cfg(target_os = "linux")] let Ok((read, write)) = rustix::pipe::pipe_with(rustix::pipe::PipeFlags::CLOEXEC) else { return None; }; + // Handle macOS + #[cfg(target_os = "macos")] + let Ok((read, write)) = rustix::pipe::pipe() else { + return None; + }; + + match unsafe { libc::fork() } { // Parent process 1.. => {