File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -270,7 +270,14 @@ fn wait_or_kill_process(
270270 match process. wait_or_timeout ( duration, None ) {
271271 Ok ( Some ( status) ) => {
272272 if preserve_status {
273- Ok ( status. code ( ) . unwrap_or_else ( || status. signal ( ) . unwrap ( ) ) )
273+ let exit_code = status. code ( ) . unwrap_or_else ( || {
274+ status. signal ( ) . unwrap_or_else ( || {
275+ // Extremely rare: process exited but we have neither exit code nor signal.
276+ // This can happen on some platforms or in unusual termination scenarios.
277+ ExitStatus :: TimeoutFailed . into ( )
278+ } )
279+ } ) ;
280+ Ok ( exit_code)
274281 } else {
275282 Ok ( ExitStatus :: TimeoutFailed . into ( ) )
276283 }
@@ -358,10 +365,14 @@ fn timeout(
358365 // structure of `wait_or_kill_process()`. They can probably be
359366 // refactored into some common function.
360367 match process. wait_or_timeout ( duration, Some ( & SIGNALED ) ) {
361- Ok ( Some ( status) ) => Err ( status
362- . code ( )
363- . unwrap_or_else ( || preserve_signal_info ( status. signal ( ) . unwrap ( ) ) )
364- . into ( ) ) ,
368+ Ok ( Some ( status) ) => {
369+ let exit_code = status. code ( ) . unwrap_or_else ( || {
370+ status
371+ . signal ( )
372+ . map_or_else ( || ExitStatus :: TimeoutFailed . into ( ) , preserve_signal_info)
373+ } ) ;
374+ Err ( exit_code. into ( ) )
375+ }
365376 Ok ( None ) => {
366377 report_if_verbose ( signal, & cmd[ 0 ] , verbose) ;
367378 send_signal ( process, signal, foreground) ;
You can’t perform that action at this time.
0 commit comments