command_group/stdlib/
unix.rs

1use std::{os::unix::process::CommandExt, process::Command};
2
3use crate::{builder::CommandGroupBuilder, GroupChild};
4
5impl CommandGroupBuilder<'_, Command> {
6	/// Executes the command as a child process group, returning a handle to it.
7	///
8	/// By default, stdin, stdout and stderr are inherited from the parent.
9	///
10	/// On Windows, this creates a job object instead of a POSIX process group.
11	///
12	/// # Examples
13	///
14	/// Basic usage:
15	///
16	/// ```no_run
17	/// use std::process::Command;
18	/// use command_group::CommandGroup;
19	///
20	/// Command::new("ls")
21	///         .group()
22	///         .spawn()
23	///         .expect("ls command failed to start");
24	/// ```
25	pub fn spawn(&mut self) -> std::io::Result<GroupChild> {
26		self.command.process_group(0).spawn().map(GroupChild::new)
27	}
28}