feat: (iso9660) directory read support
[lunaix-os.git] / lunaix-os / kernel / demos / signal_demo.c
index 616a38e9e090773b1b39fba1038dd0eb3d37ad6d..3878a1881512cba292868e1cf1cc45b730e7da20 100644 (file)
@@ -1,23 +1,21 @@
+#include <lunaix/lunaix.h>
 #include <lunaix/lunistd.h>
 #include <lunaix/lunistd.h>
-#include <lunaix/proc.h>
 #include <lunaix/signal.h>
 #include <lunaix/spike.h>
 #include <lunaix/signal.h>
 #include <lunaix/spike.h>
-#include <lunaix/syslog.h>
 #include <lunaix/types.h>
 #include <lunaix/types.h>
-
-LOG_MODULE("SIGDEMO")
+#include <ulibc/stdio.h>
 
 void __USER__
 sigchild_handler(int signum)
 {
 
 void __USER__
 sigchild_handler(int signum)
 {
-    kprintf(KINFO "SIGCHLD received\n");
+    printf("SIGCHLD received\n");
 }
 
 void __USER__
 sigsegv_handler(int signum)
 {
     pid_t pid = getpid();
 }
 
 void __USER__
 sigsegv_handler(int signum)
 {
     pid_t pid = getpid();
-    kprintf(KWARN "SIGSEGV received on process %d\n", pid);
+    printf("SIGSEGV received on process %d\n", pid);
     _exit(signum);
 }
 
     _exit(signum);
 }
 
@@ -25,7 +23,7 @@ void __USER__
 sigalrm_handler(int signum)
 {
     pid_t pid = getpid();
 sigalrm_handler(int signum)
 {
     pid_t pid = getpid();
-    kprintf(KWARN "I, pid %d, have received an alarm!\n", pid);
+    printf("I, pid %d, have received an alarm!\n", pid);
 }
 
 void __USER__
 }
 
 void __USER__
@@ -40,7 +38,7 @@ _signal_demo_main()
     int status;
     pid_t p = 0;
 
     int status;
     pid_t p = 0;
 
-    kprintf(KINFO "Child sleep 3s, parent pause.\n");
+    printf("Child sleep 3s, parent pause.\n");
     if (!fork()) {
         sleep(3);
         _exit(0);
     if (!fork()) {
         sleep(3);
         _exit(0);
@@ -48,7 +46,7 @@ _signal_demo_main()
 
     pause();
 
 
     pause();
 
-    kprintf("Parent resumed on SIGCHILD\n");
+    printf("Parent resumed on SIGCHILD\n");
 
     for (int i = 0; i < 5; i++) {
         pid_t pid = 0;
 
     for (int i = 0; i < 5; i++) {
         pid_t pid = 0;
@@ -58,26 +56,22 @@ _signal_demo_main()
             if (i == 3) {
                 i = *(int*)0xdeadc0de; // seg fault!
             }
             if (i == 3) {
                 i = *(int*)0xdeadc0de; // seg fault!
             }
-            kprintf(KINFO "%d\n", i);
+            printf("%d\n", i);
             _exit(0);
         }
             _exit(0);
         }
-        kprintf(KINFO "Forked %d\n", pid);
+        printf("Forked %d\n", pid);
     }
 
     while ((p = wait(&status)) >= 0) {
         short code = WEXITSTATUS(status);
         if (WIFSIGNALED(status)) {
     }
 
     while ((p = wait(&status)) >= 0) {
         short code = WEXITSTATUS(status);
         if (WIFSIGNALED(status)) {
-            kprintf(KINFO "Process %d terminated by signal, exit_code: %d\n",
-                    p,
-                    code);
+            printf("Process %d terminated by signal, exit_code: %d\n", p, code);
         } else if (WIFEXITED(status)) {
         } else if (WIFEXITED(status)) {
-            kprintf(KINFO "Process %d exited with code %d\n", p, code);
+            printf("Process %d exited with code %d\n", p, code);
         } else {
         } else {
-            kprintf(KWARN "Process %d aborted with code %d\n", p, code);
+            printf("Process %d aborted with code %d\n", p, code);
         }
     }
 
         }
     }
 
-    kprintf("done\n");
-
-    _exit(0);
+    printf("done\n");
 }
\ No newline at end of file
 }
\ No newline at end of file