proc: resurrect /proc/PID/stat and fix a few fields

Change-Id: I8ffcfde4db78c66ea10845a0451ae2610261f832
This commit is contained in:
Balazs Gerofi
2019-03-15 01:20:46 +09:00
committed by Dominique Martinet
parent e5c1fdf129
commit 2ce695b47b
3 changed files with 45 additions and 3 deletions

View File

@ -669,6 +669,42 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
}
if (!strcmp(p, "stat")) {
const char *comm = "exe";
char state;
if (proc->saved_cmdline) {
comm = strrchr(proc->saved_cmdline, '/');
if (comm)
comm++;
else
comm = proc->saved_cmdline;
}
switch (thread->status & (0x3f)) {
case PS_INTERRUPTIBLE:
state = 'S';
break;
case PS_UNINTERRUPTIBLE:
state = 'D';
break;
case PS_ZOMBIE:
state = 'Z';
break;
case PS_EXITED:
state = 'X';
break;
case PS_STOPPED:
state = 'T';
break;
case PS_RUNNING:
default:
if (thread->in_syscall_offload > 0) {
state = 'S';
}
else {
state = 'R';
}
}
/*
* pid (comm) state ppid
@ -695,8 +731,9 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
"%lu %lu %lu %lu " // sigignore...
"%lu %d %d %u " // cnswap...
"%u %llu %lu %ld\n", // policy...
0, "exe", 'R', 0, // pid...
0, 0, 0, 0, // pgrp...
thread->tid, comm, state,
thread->proc->ppid_parent->pid, // pid...
thread->proc->pid, 0, 0, 0, // pgrp...
0, 0L, 0L, 0L, // flags...
0L, 0L, 0L, 0L, // cmajflt...
0L, 0L, 0L, 0L, // cstime...