提交 2d18f7f4 编写于 作者: E Eric W. Biederman

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: bf719d26a5c1 ("[PATCH] distinct tgid/tid CPU usage")
Link: https://lkml.kernel.org/r/20220103213312.9144-4-ebiederm@xmission.comSigned-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
上级 907c311f
...@@ -468,6 +468,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, ...@@ -468,6 +468,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
u64 cgtime, gtime; u64 cgtime, gtime;
unsigned long rsslim = 0; unsigned long rsslim = 0;
unsigned long flags; unsigned long flags;
int exit_code = task->exit_code;
state = *get_task_state(task); state = *get_task_state(task);
vsize = eip = esp = 0; vsize = eip = esp = 0;
...@@ -531,6 +532,9 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, ...@@ -531,6 +532,9 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
maj_flt += sig->maj_flt; maj_flt += sig->maj_flt;
thread_group_cputime_adjusted(task, &utime, &stime); thread_group_cputime_adjusted(task, &utime, &stime);
gtime += sig->gtime; gtime += sig->gtime;
if (sig->flags & (SIGNAL_GROUP_EXIT | SIGNAL_STOP_STOPPED))
exit_code = sig->group_exit_code;
} }
sid = task_session_nr_ns(task, ns); sid = task_session_nr_ns(task, ns);
...@@ -630,7 +634,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, ...@@ -630,7 +634,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
seq_puts(m, " 0 0 0 0 0 0 0"); seq_puts(m, " 0 0 0 0 0 0 0");
if (permitted) if (permitted)
seq_put_decimal_ll(m, " ", task->exit_code); seq_put_decimal_ll(m, " ", exit_code);
else else
seq_puts(m, " 0"); seq_puts(m, " 0");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册