refactor: formattings
authorMinep <zelong56@gmail.com>
Wed, 15 Jun 2022 20:58:30 +0000 (21:58 +0100)
committerMinep <zelong56@gmail.com>
Wed, 15 Jun 2022 20:58:30 +0000 (21:58 +0100)
fix: avoid setpgid on group leader

lunaix-os/includes/lunaix/proc.h
lunaix-os/kernel/lxinit.c
lunaix-os/kernel/proc0.c
lunaix-os/kernel/process.c
lunaix-os/kernel/syscall.c

index a6f44700aa67ab7b59d8b6500a92beabfb0bb2af..eafae4fc43968e6f7958c8432b61c066271b4029 100644 (file)
@@ -7,6 +7,7 @@
 __LXSYSCALL(void, yield);
 
 __LXSYSCALL1(pid_t, wait, int*, status);
+
 __LXSYSCALL3(pid_t, waitpid, pid_t, pid, int*, status, int, options);
 
 #endif /* __LUNAIX_SYS_H */
index fa8458c98eca67c28e782f9a3a7948ea32d283e9..43f0f2d9381e2ba7a533696298a38d934c5b3432 100644 (file)
@@ -49,14 +49,13 @@ _lxinit_main()
     pid_t p = 0;
 
     if (!fork()) {
-        kprintf("Test no hang!");
-        sleep(12);
+        kprintf("Test no hang!\n");
+        sleep(6);
         _exit(0);
     }
 
     waitpid(-1, &status, WNOHANG);
 
-    // 这里是就是LunaixOS的第一个进程了!
     for (size_t i = 0; i < 5; i++) {
         pid_t pid = 0;
         if (!(pid = fork())) {
index dac1b55597c7400c783efcbca659ac72b6a7a390..074bcd9347c40cdf070e97c26c3127eddbc2b3b0 100644 (file)
@@ -36,6 +36,20 @@ void
 __proc0()
 {
     init_platform();
+    asm volatile("movw %0, %ax\n"
+                 "movw %ax, %es\n"
+                 "movw %ax, %ds\n"
+                 "movw %ax, %fs\n"
+                 "movw %ax, %gs\n"
+                 "pushl %0\n"
+                 "pushl %1\n"
+                 "pushl %2\n"
+                 "pushl %3\n"
+                 "retf" ::"i"(UDATA_SEG),
+                 "i"(USTACK_TOP & ~0xf),
+                 "i"(UCODE_SEG),
+                 "r"(&&usr));
+usr:
     if (!fork()) {
         asm("jmp _lxinit_main");
     }
index 64f2654af6a0d1b621e2cc7e1d1f71657a5fae8f..020dfb47fe3fe8a5a92c8b404f11005bf3a5ec03 100644 (file)
@@ -107,14 +107,14 @@ __DEFINE_LXSYSCALL2(int, setpgid, pid_t, pid, pid_t, pgid)
 
     pgid = pgid ? pgid : proc->pid;
 
-    llist_delete(&proc->grp_member);
     struct proc_info* gruppenfuhrer = get_process(pgid);
 
-    if (!gruppenfuhrer) {
+    if (!gruppenfuhrer || proc->pgid == proc->pid) {
         __current->k_status = LXINVL;
         return -1;
     }
 
+    llist_delete(&proc->grp_member);
     llist_append(&gruppenfuhrer->grp_member, &proc->grp_member);
 
     proc->pgid = pgid;
index 0d41470d8944ddff5b5ac0aba0da37309fb4ca28..ce0f2a794813dcc1a405c6d288fbdc85c2518b32 100644 (file)
@@ -1,13 +1,16 @@
-#include <lunaix/syscall.h>
 #include <arch/x86/interrupts.h>
 #include <lunaix/process.h>
 #include <lunaix/sched.h>
+#include <lunaix/syscall.h>
 #include <lunaix/syslog.h>
 
 LOG_MODULE("SYSCALL")
 
-extern void syscall_hndlr(isr_param* param);
+extern void
+syscall_hndlr(isr_param* param);
 
-void syscall_install() {
+void
+syscall_install()
+{
     intr_subscribe(LUNAIX_SYS_CALL, syscall_hndlr);
 }
\ No newline at end of file