diff options
author | Přemysl Janouch <p@janouch.name> | 2019-12-09 19:01:16 +0100 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2019-12-09 19:01:16 +0100 |
commit | 571ec74706cee1ee2ec4ac429eb0969301d6e669 (patch) | |
tree | c56c213564b3ffdfef30864e46bb423d49f4a356 | |
parent | 7cce0cc2fd47d474a58371f210a38261c222c3ec (diff) | |
download | sdn-571ec74706cee1ee2ec4ac429eb0969301d6e669.tar.gz sdn-571ec74706cee1ee2ec4ac429eb0969301d6e669.tar.xz sdn-571ec74706cee1ee2ec4ac429eb0969301d6e669.zip |
Guard against ^Z in helper programs
Resume them immediately, we are not a shell.
-rw-r--r-- | sdn.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -834,7 +834,11 @@ fun run_program (initializer_list<const char*> 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)); } |