kernel: Fix breakages in revised exit handling
authorAlan Cox <alan@linux.intel.com>
Sun, 21 Feb 2016 19:50:12 +0000 (19:50 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 21 Feb 2016 19:50:12 +0000 (19:50 +0000)
This messed up the left and right halves of the return codes.

Kernel/include/kernel.h
Kernel/include/level2.h
Kernel/process.c
Kernel/syscall_proc.c

index f5955af..21f56db 100644 (file)
@@ -47,7 +47,7 @@ From UZI by Doug Braun and UZI280 by Stefan Nitschke.
        (udata.u_ptab->p_uid == (p)->p_uid || super())
 #define pathbuf()      tmpbuf()
 #define pathfree(tb)   brelse(tb)
-#define dump_core(sig)
+#define dump_core(sig) sig
 
 #endif
 
@@ -476,6 +476,7 @@ struct s_argblk {
 #define WNOHANG                1
 #define WUNTRACED      2
 #define _WSTOPPED      0xFF
+#define W_COREDUMP     0x80
 
 /* Open() parameters. */
 
index 3aa77cf..093a0e7 100644 (file)
@@ -61,7 +61,7 @@ extern arg_t _setsid(void);
 extern arg_t _getsid(void);
 
 /* Provided by the execve support */
-extern void write_core_image(void);
+extern uint8_t write_core_image(void);
 
 /* This will change a lot in future ! */
 struct coredump {
index dec3072..0158d39 100644 (file)
@@ -434,14 +434,15 @@ void sgrpsig(uint16_t pgrp, uint8_t sig)
 }
 
 #ifdef CONFIG_LEVEL_2
-static void dump_core(uint8_t sig)
+static uint8_t dump_core(uint8_t sig)
 {
         if (!(udata.u_flags & U_FLAG_NOCORE) && ((sig == SIGQUIT || sig == SIGILL || sig == SIGTRAP ||
             sig == SIGABRT || sig == SIGBUS || sig == SIGFPE ||
             sig == SIGSEGV || sig == SIGXCPU || sig == SIGXFSZ ||
             sig == SIGSYS))) {
-               write_core_image();
+               return sig | write_core_image();
        }
+       return sig;
 }
 #endif                                    
 
@@ -489,8 +490,7 @@ void chksigs(void)
 #ifdef DEBUG
                        kprintf("process terminated by signal %d\n", j);
 #endif
-                        dump_core(j);
-                       doexit((uint16_t)j << 8);
+                        doexit(dump_core(j));
                } else if (*svec != SIG_IGN) {
                        /* Arrange to call the user routine at return */
                        udata.u_ptab->p_pending &= ~m;  // unset the bit
index 8ea506c..025d301 100644 (file)
@@ -346,7 +346,7 @@ int16_t val;
 arg_t __exit(void)
 {
        /* Deliberately chop to 8bits */
-       doexit(val & 0xFF);
+       doexit(val << 8);
        return 0;               // ... yeah. that might not happen.
 }