From 571ec74706cee1ee2ec4ac429eb0969301d6e669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Mon, 9 Dec 2019 19:01:16 +0100 Subject: Guard against ^Z in helper programs Resume them immediately, we are not a shell. --- sdn.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdn.cpp b/sdn.cpp index 8019891..9734a80 100644 --- a/sdn.cpp +++ b/sdn.cpp @@ -834,7 +834,11 @@ fun run_program (initializer_list list, const string &filename) { default: // ...and make sure of it in the parent as well (void) setpgid (child, child); - waitpid (child, &status, 0); + + // We don't provide job control--don't let us hang after ^Z + while (waitpid (child, &status, WUNTRACED) > -1 && WIFSTOPPED (status)) + if (WSTOPSIG (status) == SIGTSTP) + kill (child, SIGCONT); tcsetpgrp (STDOUT_FILENO, getpgid (0)); } -- cgit v1.2.3