Show python scripts in pstree

This commit is contained in:
Kevin Lange 2017-01-29 19:11:55 +09:00
parent 9d7d956eb1
commit 6720d8dd95
2 changed files with 21 additions and 1 deletions

View File

@ -119,6 +119,7 @@ static uint32_t proc_status_func(fs_node_t *node, uint32_t offset, uint32_t size
"SC2:\t0x%x\n"
"SC3:\t0x%x\n"
"SC4:\t0x%x\n"
"Path:\t%s\n"
,
name,
state,
@ -132,7 +133,8 @@ static uint32_t proc_status_func(fs_node_t *node, uint32_t offset, uint32_t size
proc->syscall_registers ? proc->syscall_registers->ecx : 0,
proc->syscall_registers ? proc->syscall_registers->edx : 0,
proc->syscall_registers ? proc->syscall_registers->esi : 0,
proc->syscall_registers ? proc->syscall_registers->edi : 0
proc->syscall_registers ? proc->syscall_registers->edi : 0,
proc->cmdline ? proc->cmdline[0] : "(none)"
);
size_t _bsize = strlen(buf);

View File

@ -27,6 +27,7 @@ typedef struct process {
int ppid;
int tgid;
char name[100];
char path[200];
} p_t;
#define LINE_LEN 4096
@ -53,9 +54,26 @@ p_t * build_entry(struct dirent * dent) {
sscanf(line, "%s %d", &buf, &proc->tgid);
} else if (strstr(line, "Name:") == line) {
sscanf(line, "%s %s", &buf, &proc->name);
} else if (strstr(line, "Path:") == line) {
sscanf(line, "%s %s", &buf, &proc->path);
}
}
if (!strncmp(proc->name,"python",6)) {
char * name = proc->path + strlen(proc->path) - 1;
while (1) {
if (*name == '/') {
name++;
break;
}
if (name == proc->name) break;
name--;
}
memcpy(proc->name, name, strlen(name)+1);
}
if (proc->tgid != proc->pid) {
char tmp[100] = {0};
sprintf(tmp, "{%s}", proc->name);