}
else
status = WEXITSTATUS (status);
+
+ /* child is gone, don't use the PID anymore */
+ child = (pid_t) -1;
}
else if (caught_signal)
status = caught_signal + 128;
else
status = 1;
- if (caught_signal)
+ if (caught_signal && child != (pid_t)-1)
{
fprintf (stderr, _("\nSession terminated, killing shell..."));
kill (child, SIGTERM);
if (caught_signal)
{
- sleep (2);
- kill (child, SIGKILL);
- fprintf (stderr, _(" ...killed.\n"));
+ if (child != (pid_t)-1)
+ {
+ sleep (2);
+ kill (child, SIGKILL);
+ fprintf (stderr, _(" ...killed.\n"));
+ }
/* Let's terminate itself with the received signal.
*