refactor: make the demos into dedicated files
[lunaix-os.git] / lunaix-os / kernel / lxinit.c
index 1485c3411e4d95266642876f8481f0b9b3168173..2ac93422844506d72cb21557b75aa938ee1defec 100644 (file)
@@ -5,7 +5,6 @@
 #include <lunaix/mm/kalloc.h>
 #include <lunaix/mm/vmm.h>
 #include <lunaix/proc.h>
 #include <lunaix/mm/kalloc.h>
 #include <lunaix/mm/vmm.h>
 #include <lunaix/proc.h>
-#include <lunaix/signal.h>
 #include <lunaix/spike.h>
 #include <lunaix/syslog.h>
 #include <lunaix/timer.h>
 #include <lunaix/spike.h>
 #include <lunaix/syslog.h>
 #include <lunaix/timer.h>
@@ -19,12 +18,6 @@ LOG_MODULE("INIT")
 #define WAIT_DEMO
 #define IN_USER_MODE
 
 #define WAIT_DEMO
 #define IN_USER_MODE
 
-void __USER__
-sigchild_handler(int signum)
-{
-    kprintf(KINFO "SIGCHLD received\n");
-}
-
 void __USER__
 _lxinit_main()
 {
 void __USER__
 _lxinit_main()
 {
@@ -38,8 +31,6 @@ _lxinit_main()
     }
 #endif
 
     }
 #endif
 
-    signal(_SIGCHLD, sigchild_handler);
-
     int status;
 #ifdef WAIT_DEMO
     // 测试wait
     int status;
 #ifdef WAIT_DEMO
     // 测试wait
@@ -50,6 +41,7 @@ _lxinit_main()
         kprintf("I am child, I am about to terminated\n");
         _exit(1);
     }
         kprintf("I am child, I am about to terminated\n");
         _exit(1);
     }
+    wait(&status);
     pid_t child = wait(&status);
     kprintf("I am parent, my child (%d) terminated normally with code: %d.\n",
             child,
     pid_t child = wait(&status);
     kprintf("I am parent, my child (%d) terminated normally with code: %d.\n",
             child,
@@ -66,7 +58,7 @@ _lxinit_main()
 
     waitpid(-1, &status, WNOHANG);
 
 
     waitpid(-1, &status, WNOHANG);
 
-    for (size_t i = 0; i < 10; i++) {
+    for (size_t i = 0; i < 5; i++) {
         pid_t pid = 0;
         if (!(pid = fork())) {
             sleep(i);
         pid_t pid = 0;
         if (!(pid = fork())) {
             sleep(i);