aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@openvz.org>2012-05-31 19:26:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-31 20:49:32 -0400
commit5b172087f99189416d5f47fd7ab5e6fb762a9ba3 (patch)
tree2619444e8ceee40df80814a1004687ac3d7f1eda
parentd97b46a64674a267bc41c9e16132ee2a98c3347d (diff)
c/r: procfs: add arg_start/end, env_start/end and exit_code members to /proc/$pid/stat
We would like to have an ability to restore command line arguments and program environment pointers but first we need to obtain them somehow. Thus we put these values into /proc/$pid/stat. The exit_code is needed to restore zombie tasks. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Acked-by: Kees Cook <keescook@chromium.org> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Serge Hallyn <serge.hallyn@canonical.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Tejun Heo <tj@kernel.org> Cc: Andrew Vagin <avagin@openvz.org> Cc: Vasiliy Kulikov <segoon@openwall.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/filesystems/proc.txt5
-rw-r--r--fs/proc/array.c20
2 files changed, 22 insertions, 3 deletions
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index d8d3f9a8e5a3..fb0a6aeb936c 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -311,6 +311,11 @@ Table 1-4: Contents of the stat files (as of 2.6.30-rc7)
311 start_data address above which program data+bss is placed 311 start_data address above which program data+bss is placed
312 end_data address below which program data+bss is placed 312 end_data address below which program data+bss is placed
313 start_brk address above which program heap can be expanded with brk() 313 start_brk address above which program heap can be expanded with brk()
314 arg_start address above which program command line is placed
315 arg_end address below which program command line is placed
316 env_start address above which program environment is placed
317 env_end address below which program environment is placed
318 exit_code the thread's exit_code in the form reported by the waitpid system call
314.............................................................................. 319..............................................................................
315 320
316The /proc/PID/maps file containing the currently mapped memory regions and 321The /proc/PID/maps file containing the currently mapped memory regions and
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 62887e39a2de..c1c207c36cae 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -517,9 +517,23 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
517 seq_put_decimal_ull(m, ' ', delayacct_blkio_ticks(task)); 517 seq_put_decimal_ull(m, ' ', delayacct_blkio_ticks(task));
518 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime)); 518 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
519 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime)); 519 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
520 seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->start_data : 0); 520
521 seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->end_data : 0); 521 if (mm && permitted) {
522 seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->start_brk : 0); 522 seq_put_decimal_ull(m, ' ', mm->start_data);
523 seq_put_decimal_ull(m, ' ', mm->end_data);
524 seq_put_decimal_ull(m, ' ', mm->start_brk);
525 seq_put_decimal_ull(m, ' ', mm->arg_start);
526 seq_put_decimal_ull(m, ' ', mm->arg_end);
527 seq_put_decimal_ull(m, ' ', mm->env_start);
528 seq_put_decimal_ull(m, ' ', mm->env_end);
529 } else
530 seq_printf(m, " 0 0 0 0 0 0 0");
531
532 if (permitted)
533 seq_put_decimal_ll(m, ' ', task->exit_code);
534 else
535 seq_put_decimal_ll(m, ' ', 0);
536
523 seq_putc(m, '\n'); 537 seq_putc(m, '\n');
524 if (mm) 538 if (mm)
525 mmput(mm); 539 mmput(mm);