File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,9 @@ create_watching_parent (void)
368368 }
369369 else
370370 status = WEXITSTATUS (status );
371+
372+ /* child is gone, don't use the PID anymore */
373+ child = (pid_t ) - 1 ;
371374 }
372375 else if (caught_signal )
373376 status = caught_signal + 128 ;
@@ -377,7 +380,7 @@ create_watching_parent (void)
377380 else
378381 status = 1 ;
379382
380- if (caught_signal )
383+ if (caught_signal && child != ( pid_t ) - 1 )
381384 {
382385 fprintf (stderr , _ ("\nSession terminated, killing shell..." ));
383386 kill (child , SIGTERM );
@@ -387,9 +390,12 @@ create_watching_parent (void)
387390
388391 if (caught_signal )
389392 {
390- sleep (2 );
391- kill (child , SIGKILL );
392- fprintf (stderr , _ (" ...killed.\n" ));
393+ if (child != (pid_t )- 1 )
394+ {
395+ sleep (2 );
396+ kill (child , SIGKILL );
397+ fprintf (stderr , _ (" ...killed.\n" ));
398+ }
393399
394400 /* Let's terminate itself with the received signal.
395401 *
You can’t perform that action at this time.
0 commit comments