summaryrefslogtreecommitdiffstats
path: root/02_exercise/process.c
diff options
context:
space:
mode:
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);