@@ -33,13 +33,8 @@ pub(crate) enum CommandSpawnResult {
33
33
34
34
impl CommandSpawnResult {
35
35
// TODO: jobs: remove `no_wait`; it doesn't make any sense
36
- // TODO: jobs: figure out how to remove 'shell'
37
36
#[ allow( clippy:: too_many_lines) ]
38
- pub async fn wait (
39
- self ,
40
- shell : & mut Shell ,
41
- no_wait : bool ,
42
- ) -> Result < CommandWaitResult , error:: Error > {
37
+ pub async fn wait ( self , no_wait : bool ) -> Result < CommandWaitResult , error:: Error > {
43
38
#[ allow( clippy:: ignored_unit_patterns) ]
44
39
match self {
45
40
CommandSpawnResult :: SpawnedProcess ( mut child) => {
@@ -61,10 +56,6 @@ impl CommandSpawnResult {
61
56
) ,
62
57
} ;
63
58
64
- if shell. options . interactive {
65
- sys:: terminal:: move_self_to_foreground ( ) ?;
66
- }
67
-
68
59
Ok ( command_wait_result)
69
60
}
70
61
CommandSpawnResult :: ImmediateExit ( exit_code) => Ok (
@@ -354,16 +345,15 @@ pub(crate) fn execute_external_command(
354
345
) ?;
355
346
356
347
// Set up process group state.
357
- let required_pgid = if new_pg {
358
- let required_pgid = process_group_id. unwrap_or ( 0 ) ;
359
-
348
+ if new_pg {
349
+ // We need to set up a new process group.
360
350
#[ cfg( unix) ]
361
- cmd. process_group ( required_pgid ) ;
362
-
363
- required_pgid
364
- } else {
365
- 0
366
- } ;
351
+ cmd. process_group ( 0 ) ;
352
+ } else if let Some ( pgid ) = process_group_id {
353
+ // We need to join an established process group.
354
+ # [ cfg ( unix ) ]
355
+ cmd . process_group ( * pgid ) ;
356
+ }
367
357
368
358
// Register some code to run in the forked child process before it execs
369
359
// the target command.
@@ -377,7 +367,7 @@ pub(crate) fn execute_external_command(
377
367
// When tracing is enabled, report.
378
368
tracing:: debug!(
379
369
target: trace_categories:: COMMANDS ,
380
- "Spawning: pgid={required_pgid} cmd='{} {}'" ,
370
+ "Spawning: cmd='{} {}'" ,
381
371
cmd. get_program( ) . to_string_lossy( ) . to_string( ) ,
382
372
cmd. get_args( )
383
373
. map( |a| a. to_string_lossy( ) . to_string( ) )
@@ -387,11 +377,11 @@ pub(crate) fn execute_external_command(
387
377
match sys:: process:: spawn ( cmd) {
388
378
Ok ( child) => {
389
379
// Retrieve the pid.
390
- let pid = child. id ( ) ;
380
+ #[ allow( clippy:: cast_possible_wrap) ]
381
+ let pid = child. id ( ) . map ( |id| id as i32 ) ;
391
382
if let Some ( pid) = & pid {
392
- #[ allow( clippy:: cast_possible_wrap) ]
393
- if required_pgid == 0 {
394
- * process_group_id = Some ( * pid as i32 ) ;
383
+ if new_pg {
384
+ * process_group_id = Some ( * pid) ;
395
385
}
396
386
} else {
397
387
tracing:: warn!( "could not retrieve pid for child process" ) ;
0 commit comments