File tree 1 file changed +30
-3
lines changed
1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -148,9 +148,36 @@ pub trait CommandExt: Sealed {
148
148
where
149
149
S : AsRef < OsStr > ;
150
150
151
- /// Sets the process group ID of the child process. Translates to a `setpgid` call in the child
152
- /// process.
153
- #[ unstable( feature = "process_set_process_group" , issue = "93857" ) ]
151
+ /// Sets the process group ID (PGID) of the child process. Equivalent to a
152
+ /// `setpgid` call in the child process, but may be more efficient.
153
+ ///
154
+ /// Process groups determine which processes receive signals.
155
+ ///
156
+ /// # Examples
157
+ ///
158
+ /// Pressing Ctrl-C in a terminal will send SIGINT to all processes in
159
+ /// the current foreground process group. By spawning the `sleep`
160
+ /// subprocess in a new process group, it will not receive SIGINT from the
161
+ /// terminal.
162
+ ///
163
+ /// The parent process could install a signal handler and manage the
164
+ /// subprocess on its own terms.
165
+ ///
166
+ /// A process group ID of 0 will use the process ID as the PGID.
167
+ ///
168
+ /// ```no_run
169
+ /// use std::process::Command;
170
+ /// use std::os::unix::process::CommandExt;
171
+ ///
172
+ /// Command::new("sleep")
173
+ /// .arg("10")
174
+ /// .process_group(0)
175
+ /// .spawn()?
176
+ /// .wait()?;
177
+ /// #
178
+ /// # Ok::<_, Box<dyn std::error::Error>>(())
179
+ /// ```
180
+ #[ stable( feature = "process_set_process_group" , since = "1.64.0" ) ]
154
181
fn process_group ( & mut self , pgroup : i32 ) -> & mut process:: Command ;
155
182
}
156
183
You can’t perform that action at this time.
0 commit comments