summaryrefslogtreecommitdiff
path: root/sdn.cpp
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2019-12-09 19:01:16 +0100
committerPřemysl Janouch <p@janouch.name>2019-12-09 19:01:16 +0100
commit571ec74706cee1ee2ec4ac429eb0969301d6e669 (patch)
treec56c213564b3ffdfef30864e46bb423d49f4a356 /sdn.cpp
parent7cce0cc2fd47d474a58371f210a38261c222c3ec (diff)
downloadsdn-571ec74706cee1ee2ec4ac429eb0969301d6e669.tar.gz
sdn-571ec74706cee1ee2ec4ac429eb0969301d6e669.tar.xz
sdn-571ec74706cee1ee2ec4ac429eb0969301d6e669.zip
Guard against ^Z in helper programs
Resume them immediately, we are not a shell.
Diffstat (limited to 'sdn.cpp')
-rw-r--r--sdn.cpp6
1 files changed, 5 insertions, 1 deletions
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<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));
}