Created
December 27, 2014 20:06
-
-
Save tuxillo/0d6da2ebe6590e522d77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sys/platform/vkernel64/platform/init.c b/sys/platform/vkernel64/platform/init.c | |
index 8183e24..5d1ea92 100644 | |
--- a/sys/platform/vkernel64/platform/init.c | |
+++ b/sys/platform/vkernel64/platform/init.c | |
@@ -143,6 +143,9 @@ static int unix_connect(const char *path); | |
static void usage_err(const char *ctl, ...); | |
static void usage_help(_Bool); | |
static void init_locks(void); | |
+static void handle_term(int); | |
+ | |
+pid_t childpid; | |
static int save_ac; | |
static char **save_av; | |
@@ -178,7 +181,6 @@ int main(int ac, char **av) { | |
size_t msize; | |
size_t kenv_size; | |
size_t kenv_size2; | |
- pid_t pid; | |
int status; | |
struct sigaction sa; | |
@@ -194,7 +196,7 @@ int main(int ac, char **av) { | |
exit(1); | |
} | |
- while ((pid = fork()) != 0) { | |
+ while ((childpid = fork()) != 0) { | |
/* Ignore signals */ | |
bzero(&sa, sizeof(sa)); | |
sigemptyset(&sa.sa_mask); | |
@@ -203,11 +205,14 @@ int main(int ac, char **av) { | |
sigaction(SIGQUIT, &sa, NULL); | |
sigaction(SIGHUP, &sa, NULL); | |
+ sa.sa_handler = handle_term; | |
+ sigaction(SIGTERM, &sa, NULL); | |
+ | |
/* | |
* Wait for child to terminate, exit if | |
* someone stole our child. | |
*/ | |
- while (waitpid(pid, &status, 0) != pid) { | |
+ while (waitpid(childpid, &status, 0) != childpid) { | |
if (errno == ECHILD) | |
exit(1); | |
} | |
@@ -469,6 +474,13 @@ int main(int ac, char **av) { | |
exit(EX_SOFTWARE); | |
} | |
+static | |
+void | |
+handle_term(int sig) | |
+{ | |
+ kill(childpid, sig); | |
+} | |
+ | |
/* | |
* Initialize system memory. This is the virtual kernel's 'RAM'. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment