summaryrefslogtreecommitdiffstats
path: root/02_exercise/process.c
diff options
context:
space:
mode:
authorNiklas Halle <niklas@niklashalle.net>2020-05-25 19:42:24 +0200
committerNiklas Halle <niklas@niklashalle.net>2020-05-25 19:42:24 +0200
commit589ec07d1ec29e9e33714fcc0f213e79c1f36a9a (patch)
tree785e8d77493c0eeac4ea94799daf24f75ad2016d /02_exercise/process.c
parent41775b83ad93264b487bf0dc353b145922ee6d73 (diff)
downloadbetriebssysteme-fixing_signals.tar.gz
betriebssysteme-fixing_signals.zip
DO NOT MERGE, use previous. Trying to get ctrl-z to work.. no success yet, maybe breaks stufffixing_signals
Diffstat (limited to '02_exercise/process.c')
-rw-r--r--02_exercise/process.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/02_exercise/process.c b/02_exercise/process.c
index 0b69074..2479955 100644
--- a/02_exercise/process.c
+++ b/02_exercise/process.c
@@ -3,10 +3,11 @@
#include <string.h>
#include <unistd.h>
#include <wait.h>
+#include <errno.h>
#include "array.h"
#include "process.h"
-
+#include "signal_handler.h"
// given a substring of a line tries to parse out as much information as possible
int parse_command(char const *line, char const *end, process *p) {
@@ -142,7 +143,12 @@ int exec_command(process p) {
printf("[%i]\n", p.pid);
if (waitpid(p.pid, &status, p.blocking ? 0 : WNOHANG) < 0) {
- fprintf(stderr, "wait error'ed out\n");
+ if (EINTR == errno) {
+ // cancelled by ctrl-c
+ handle_interrupt(p.pid);
+ } else {
+ perror("Could not wait for process");
+ }
}
return WEXITSTATUS(status);