commit ee0825d
Michael Forney
·
2016-10-24 09:04:29 +0000 UTC
parent 40a3700
launch: Handle SIGCHLD during posix_spawn call
1 files changed,
+5,
-5
+5,
-5
1@@ -130,7 +130,8 @@ cleanup(void)
2 stop_devices(false);
3 ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt);
4
5- kill(child_pid, SIGTERM);
6+ if (child_pid)
7+ kill(child_pid, SIGTERM);
8 }
9
10 void __attribute__((noreturn, format(printf, 1, 2)))
11@@ -144,12 +145,9 @@ die(const char *format, ...)
12
13 if (format[0] && format[strlen(format) - 1] == ':')
14 fprintf(stderr, " %s", strerror(errno));
15-
16 fputc('\n', stderr);
17
18- if (child_pid)
19- cleanup();
20-
21+ cleanup();
22 exit(EXIT_FAILURE);
23 }
24
25@@ -178,6 +176,8 @@ handle_chld(int signal)
26 {
27 int status;
28
29+ if (!child_pid)
30+ return;
31 wait(&status);
32 cleanup();
33 exit(WEXITSTATUS(status));