]> git.hungrycats.org Git - linux/commitdiff
[PATCH] threaded coredumps, tcore-fixes-2.5.51-A0
authorIngo Molnar <mingo@elte.hu>
Sun, 15 Dec 2002 03:44:20 +0000 (19:44 -0800)
committerIngo Molnar <mingo@elte.hu>
Sun, 15 Dec 2002 03:44:20 +0000 (19:44 -0800)
This fixes one more threaded-coredumps detail reported by the glibc
people: all threads taken down by the coredump code should report the
proper exit code.  We can do this rather easily via the group_exit
mechanism.  'Other' threads used to report SIGKILL, which was highly
confusing as the shell often displayed the 'Killed' message instead of a
'Segmentation fault' message.

Another missing bit was the 0x80 bit set in the exit status for all
threads, if the coredump was successful.  (it's safe to set this bit in
->sig->group_exit_code in an unlocked way because all threads are
artificially descheduled by the coredump code.)

fs/exec.c
include/linux/binfmts.h
kernel/signal.c

index 4c0937c43144364b89ceb5448cb8f2402f41c8b2..1699f5bdf92e1e4bed72d3f1b95c81780546856e 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1268,7 +1268,7 @@ static void coredump_wait(struct mm_struct *mm)
        BUG_ON(mm->core_waiters);
 }
 
-int do_coredump(long signr, struct pt_regs * regs)
+int do_coredump(long signr, int exit_code, struct pt_regs * regs)
 {
        char corename[CORENAME_MAX_SIZE + 1];
        struct mm_struct *mm = current->mm;
@@ -1288,6 +1288,8 @@ int do_coredump(long signr, struct pt_regs * regs)
        }
        mm->dumpable = 0;
        init_completion(&mm->core_done);
+       current->sig->group_exit = 1;
+       current->sig->group_exit_code = exit_code;
        coredump_wait(mm);
 
        if (current->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump)
@@ -1314,6 +1316,7 @@ int do_coredump(long signr, struct pt_regs * regs)
 
        retval = binfmt->core_dump(signr, regs, file);
 
+       current->sig->group_exit_code |= 0x80;
 close_fail:
        filp_close(file, NULL);
 fail_unlock:
index dfea0f47ed3e1629cbb24cb7273554c0fadd4b19..ae1b454395b5a3be2a3acd79ed1e04794a68ac51 100644 (file)
@@ -57,7 +57,7 @@ extern int setup_arg_pages(struct linux_binprm * bprm);
 extern int copy_strings(int argc,char ** argv,struct linux_binprm *bprm); 
 extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
 extern void compute_creds(struct linux_binprm *binprm);
-extern int do_coredump(long signr, struct pt_regs * regs);
+extern int do_coredump(long signr, int exit_code, struct pt_regs * regs);
 extern void set_binfmt(struct linux_binfmt *new);
 
 
index c3e602f2822a9e3ef62f50e09224d674557f495f..d617fddfb60adfdb440ed3dd3ba8f201d9e4a42b 100644 (file)
@@ -1313,7 +1313,7 @@ int get_signal_to_deliver(siginfo_t *info, struct pt_regs *regs)
                        case SIGQUIT: case SIGILL: case SIGTRAP:
                        case SIGABRT: case SIGFPE: case SIGSEGV:
                        case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ:
-                               if (do_coredump(signr, regs))
+                               if (do_coredump(signr, exit_code, regs))
                                        exit_code |= 0x80;
                                /* FALLTHRU */