X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/8fdcd1575a97862975fa019f09c00453a2a7d8bb..474a5dd282586c31abfefc7953f148acdc226731:/lunaix-os/kernel/lxinit.c diff --git a/lunaix-os/kernel/lxinit.c b/lunaix-os/kernel/lxinit.c index 57e2bda..2de87c5 100644 --- a/lunaix-os/kernel/lxinit.c +++ b/lunaix-os/kernel/lxinit.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,12 @@ LOG_MODULE("INIT") #define WAIT_DEMO #define IN_USER_MODE +void __USER__ +sigchild_handler(int signum) +{ + kprintf(KINFO "SIGCHLD received\n"); +} + void __USER__ _lxinit_main() { @@ -31,6 +38,8 @@ _lxinit_main() } #endif + signal(_SIGCHLD, sigchild_handler); + int status; #ifdef WAIT_DEMO // 测试wait @@ -41,6 +50,7 @@ _lxinit_main() kprintf("I am child, I am about to terminated\n"); _exit(1); } + pause(); pid_t child = wait(&status); kprintf("I am parent, my child (%d) terminated normally with code: %d.\n", child, @@ -57,7 +67,7 @@ _lxinit_main() waitpid(-1, &status, WNOHANG); - for (size_t i = 0; i < 5; i++) { + for (size_t i = 0; i < 10; i++) { pid_t pid = 0; if (!(pid = fork())) { sleep(i);