die_errno("fork");
if (pid > 0) { /* parent */
int wstatus;
- if (waitpid(pid, &wstatus, 0) < 0)
+ if (waitpid(pid, &wstatus, WUNTRACED) < 0)
die_errno("waitp");
+ /*
+ * If the user shuts down the container from an interactive
+ * com_enter() shell, the nsenter process receives SIGSTOP
+ * because the container shuts down the controlling tty,
+ * causing the shell to hang. Avoid this by letting the process
+ * continue once.
+ */
+ if (WIFSTOPPED(wstatus))
+ kill(pid, SIGCONT);
if (!WIFEXITED(wstatus))
return false;
if (WEXITSTATUS(wstatus) != EXIT_SUCCESS)