Commit acfd1d7f authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

crtools: Fix command line parsing in parse_pid_stat

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 1e073d05
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define PROC_PARSE_H__ #define PROC_PARSE_H__
#define TASK_COMM_LEN 16 #define TASK_COMM_LEN 16
#define TASK_COMM_LEN_FMT "(%15s)"
struct proc_pid_stat { struct proc_pid_stat {
int pid; int pid;
......
...@@ -186,9 +186,10 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s) ...@@ -186,9 +186,10 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s)
memset(s, 0, sizeof(*s)); memset(s, 0, sizeof(*s));
fscanf(f, fscanf(f,
"%d (%s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld " "%d " TASK_COMM_LEN_FMT " %c %d %d %d %d %d %u %lu %lu %lu %lu "
"%ld %d %d %llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu " "%lu %lu %ld %ld %ld %ld %d %d %llu %lu %ld %lu %lu %lu %lu "
"%lu %lu %lu %d %d %u %u %llu %lu %ld %lu %lu %lu", "%lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld "
"%lu %lu %lu",
&s->pid, &s->pid,
s->comm, s->comm,
&s->state, &s->state,
...@@ -237,7 +238,7 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s) ...@@ -237,7 +238,7 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s)
&s->end_data, &s->end_data,
&s->start_brk); &s->start_brk);
s->comm[strlen(s->comm) - 1] = '\0'; /* trim the ending ) */ s->comm[TASK_COMM_LEN-1] = '\0';
fclose(f); fclose(f);
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment