feat: nearly complete POSIX.1-2008 compliant terminal interface implementation
[lunaix-os.git] / lunaix-os / kernel / process / signal.c
index 8c4322f442a9fd33680b4ebbb6ba327fb91170c5..9989425dc1f42fabee8e1ddb6681c843454e43c0 100644 (file)
@@ -6,15 +6,19 @@
 #include <lunaix/syscall.h>
 #include <lunaix/syslog.h>
 
 #include <lunaix/syscall.h>
 #include <lunaix/syslog.h>
 
-LOG_MODULE("SIG")
-
 #include <klibc/string.h>
 
 #include <klibc/string.h>
 
+#include <sys/mm/mempart.h>
+
+LOG_MODULE("SIG")
+
 extern struct scheduler sched_ctx; /* kernel/sched.c */
 
 #define UNMASKABLE (sigset(SIGKILL) | sigset(SIGTERM))
 #define TERMSIG (sigset(SIGSEGV) | sigset(SIGINT) | UNMASKABLE)
 #define CORE (sigset(SIGSEGV))
 extern struct scheduler sched_ctx; /* kernel/sched.c */
 
 #define UNMASKABLE (sigset(SIGKILL) | sigset(SIGTERM))
 #define TERMSIG (sigset(SIGSEGV) | sigset(SIGINT) | UNMASKABLE)
 #define CORE (sigset(SIGSEGV))
+#define within_kstack(addr)                                                    \
+    (KERNEL_STACK <= (addr) && (addr) <= KERNEL_STACK_END)
 
 static inline void
 signal_terminate(int errcode)
 
 static inline void
 signal_terminate(int errcode)
@@ -57,7 +61,7 @@ signal_dispatch()
 
     ptr_t ustack = __current->ustack_top;
 
 
     ptr_t ustack = __current->ustack_top;
 
-    if ((int)(ustack - USTACK_END) < (int)sizeof(struct proc_sig)) {
+    if ((int)(ustack - USR_STACK) < (int)sizeof(struct proc_sig)) {
         // 用户栈没有空间存放信号上下文
         return 0;
     }
         // 用户栈没有空间存放信号上下文
         return 0;
     }
@@ -107,7 +111,7 @@ signal_send(pid_t pid, int signum)
     } else if (!pid) {
         proc = __current;
         goto send_grp;
     } else if (!pid) {
         proc = __current;
         goto send_grp;
-    } else if (pid < -1) {
+    } else if (pid < 0) {
         proc = get_process(-pid);
         goto send_grp;
     } else {
         proc = get_process(-pid);
         goto send_grp;
     } else {