commit 70e9715
Michael Forney
·
2018-11-14 08:31:22 +0000 UTC
parent f195793
launch: Don't need to keep track of child PID
1 files changed,
+3,
-7
+3,
-7
1@@ -55,8 +55,6 @@
2
3 #define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array)[0])
4
5-pid_t child_pid;
6-
7 static struct {
8 int socket;
9 int input_fds[128], num_input_fds;
10@@ -146,8 +144,7 @@ cleanup(void)
11 stop_devices(false);
12 ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt);
13
14- if (child_pid)
15- kill(child_pid, SIGTERM);
16+ kill(0, SIGTERM);
17 }
18
19 static void
20@@ -392,8 +389,6 @@ run(int fd) {
21 continue;
22 switch (sig) {
23 case SIGCHLD:
24- if (!child_pid)
25- break;
26 wait(&status);
27 cleanup();
28 exit(WEXITSTATUS(status));
29@@ -421,6 +416,7 @@ main(int argc, char *argv[])
30 .sa_flags = SA_RESTART,
31 };
32 sigset_t set;
33+ pid_t pid;
34 posix_spawnattr_t attr;
35
36 while ((option = getopt(argc, argv, "nt:")) != -1) {
37@@ -479,7 +475,7 @@ main(int argc, char *argv[])
38 sigemptyset(&set);
39 if (posix_spawnattr_setsigmask(&attr, &set) != 0)
40 die("failed to set spawnattr sigmask:");
41- if (posix_spawnp(&child_pid, argv[optind], NULL, &attr, argv + optind, environ) != 0)
42+ if (posix_spawnp(&pid, argv[optind], NULL, &attr, argv + optind, environ) != 0)
43 die("failed to spawn server:");
44
45 run(sock[0]);