Skip to content

Commit 2d18f7f

Browse files
committed
exit: Use the correct exit_code in /proc/<pid>/stat
Since do_proc_statt was modified to return process wide values instead of per task values the exit_code calculation has never been updated. Update it now to return the process wide exit_code when it is requested and available. History-Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Fixes: bf719d2 ("[PATCH] distinct tgid/tid CPU usage") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 907c311 commit 2d18f7f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/proc/array.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
468468
u64 cgtime, gtime;
469469
unsigned long rsslim = 0;
470470
unsigned long flags;
471+
int exit_code = task->exit_code;
471472

472473
state = *get_task_state(task);
473474
vsize = eip = esp = 0;
@@ -531,6 +532,9 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
531532
maj_flt += sig->maj_flt;
532533
thread_group_cputime_adjusted(task, &utime, &stime);
533534
gtime += sig->gtime;
535+
536+
if (sig->flags & (SIGNAL_GROUP_EXIT | SIGNAL_STOP_STOPPED))
537+
exit_code = sig->group_exit_code;
534538
}
535539

536540
sid = task_session_nr_ns(task, ns);
@@ -630,7 +634,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
630634
seq_puts(m, " 0 0 0 0 0 0 0");
631635

632636
if (permitted)
633-
seq_put_decimal_ll(m, " ", task->exit_code);
637+
seq_put_decimal_ll(m, " ", exit_code);
634638
else
635639
seq_puts(m, " 0");
636640

0 commit comments

Comments
 (0)