55 #include <linux/types.h>
56 #include <linux/errno.h>
57 #include <linux/time.h>
58 #include <linux/kernel.h>
60 #include <linux/tty.h>
61 #include <linux/string.h>
62 #include <linux/mman.h>
72 #include <linux/signal.h>
82 #include <linux/ptrace.h>
86 #include <asm/pgtable.h>
87 #include <asm/processor.h>
95 char tcomm[
sizeof(p->
comm)];
104 while (i && (buf < end)) {
105 unsigned char c = *
name;
135 static const char *
const task_state_array[] = {
148 static inline const char *get_task_state(
struct task_struct *tsk)
151 const char *
const *p = &task_state_array[0];
173 ppid = pid_alive(p) ?
179 tpid = task_pid_nr_ns(tracer, ns);
188 "Uid:\t%d\t%d\t%d\t%d\n"
189 "Gid:\t%d\t%d\t%d\t%d\n",
223 static void render_sigset_t(
struct seq_file *m,
const char *
header,
252 for (i = 1; i <=
_NSIG; ++
i, ++
k) {
265 unsigned long qsize = 0;
266 unsigned long qlim = 0;
268 sigemptyset(&pending);
269 sigemptyset(&shpending);
270 sigemptyset(&blocked);
271 sigemptyset(&ignored);
272 sigemptyset(&caught);
274 if (lock_task_sighand(p, &flags)) {
276 shpending = p->
signal->shared_pending.signal;
278 collect_sigign_sigcatch(p, &ignored, &caught);
279 num_threads = get_nr_threads(p);
284 unlock_task_sighand(p, &flags);
288 seq_printf(m,
"SigQ:\t%lu/%lu\n", qsize, qlim);
291 render_sigset_t(m,
"SigPnd:\t", &pending);
292 render_sigset_t(m,
"ShdPnd:\t", &shpending);
293 render_sigset_t(m,
"SigBlk:\t", &blocked);
294 render_sigset_t(m,
"SigIgn:\t", &ignored);
295 render_sigset_t(m,
"SigCgt:\t", &caught);
298 static void render_cap_t(
struct seq_file *m,
const char *header,
313 const struct cred *cred;
324 render_cap_t(m,
"CapInh:\t", &cap_inheritable);
325 render_cap_t(m,
"CapPrm:\t", &cap_permitted);
326 render_cap_t(m,
"CapEff:\t", &cap_effective);
327 render_cap_t(m,
"CapBnd:\t", &cap_bset);
330 static inline void task_context_switch_counts(
struct seq_file *m,
333 seq_printf(m,
"voluntary_ctxt_switches:\t%lu\n"
334 "nonvoluntary_ctxt_switches:\t%lu\n",
344 seq_puts(m,
"Cpus_allowed_list:\t");
355 task_state(m, ns, pid, task);
363 task_cpus_allowed(m, task);
365 task_context_switch_counts(m, task);
372 unsigned long vsize, eip,
esp, wchan = ~0
UL;
374 int tty_pgrp = -1, tty_nr = 0;
382 unsigned long cmin_flt = 0, cmaj_flt = 0;
383 unsigned long min_flt = 0, maj_flt = 0;
386 unsigned long rsslim = 0;
387 char tcomm[
sizeof(task->
comm)];
390 state = *get_task_state(task);
391 vsize = eip = esp = 0;
404 sigemptyset(&sigign);
405 sigemptyset(&sigcatch);
406 cutime = cstime = utime = stime = 0;
409 if (lock_task_sighand(task, &flags)) {
419 num_threads = get_nr_threads(task);
420 collect_sigign_sigcatch(task, &sigign, &sigcatch);
445 sid = task_session_nr_ns(task, ns);
447 pgid = task_pgrp_nr_ns(task, ns);
449 unlock_task_sighand(task, &flags);
452 if (permitted && (!whole || num_threads < 2))
521 if (mm && permitted) {
546 return do_task_stat(m, ns, pid, task, 0);
552 return do_task_stat(m, ns, pid, task, 1);
583 #ifdef CONFIG_CHECKPOINT_RESTORE
585 get_children_pid(
struct inode *
inode,
struct pid *pid_prev, loff_t
pos)
588 struct pid *pid =
NULL;
603 !(list_empty(&task->
sibling))) {
608 pid = get_pid(task_pid(task));
630 pid = get_pid(task_pid(task));
640 static int children_seq_show(
struct seq_file *seq,
void *
v)
642 struct inode *inode = seq->
private;
649 static void *children_seq_start(
struct seq_file *seq, loff_t *pos)
654 static void *children_seq_next(
struct seq_file *seq,
void *
v, loff_t *pos)
658 pid = get_children_pid(seq->
private, v, *pos + 1);
665 static void children_seq_stop(
struct seq_file *seq,
void *
v)
671 .
start = children_seq_start,
672 .next = children_seq_next,
673 .stop = children_seq_stop,
674 .show = children_seq_show,
677 static int children_seq_open(
struct inode *inode,
struct file *
file)
682 ret =
seq_open(file, &children_seq_ops);
692 int children_seq_release(
struct inode *inode,
struct file *file)
699 .open = children_seq_open,
702 .release = children_seq_release,