1. 程式人生 > 其它 >Linux:kernel:神祕返回值139

Linux:kernel:神祕返回值139

[[email protected] test]# ./a.out
abc=abc, temp=abc, remain=def
Segmentation fault (core dumped)
[[email protected] test]# echo $?
139
這裡的139 是sig 11 處理產生coredump之後,在11這個基礎上或了一個0x80,為什麼要或這個值呢;
static void coredump_finish(struct mm_struct *mm, bool core_dumped)
{
struct core_thread *curr, *next;

struct task_struct *task;
spin_lock_irq(&current->sighand->siglock);
if (core_dumped && !__fatal_signal_pending(current))
current->signal->group_exit_code |= 0x80; 這裡如果原有signal是11,返回的是139

commit b9daa0066d792983da59154af3ae486eff9b9aa1
Author: Ingo Molnar [email protected]
Date: Sat Dec 14 19:44:20 2002 -0800

[PATCH] threaded coredumps, tcore-fixes-2.5.51-A0

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.)

還沒找到0x80這個bit是什麼含義;
這也就是為什麼靜態檢查工具為什麼不讓用magic number的原因。

		infop->cause = (status & 0x80) ? CLD_DUMPED : CLD_KILLED;

通過這個推測,可能是已經產生core檔案。