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
#ifndef 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 {
int pid;
......
......@@ -186,9 +186,10 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s)
memset(s, 0, sizeof(*s));
fscanf(f,
"%d (%s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %ld %ld %ld "
"%ld %d %d %llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%lu %lu %lu %d %d %u %u %llu %lu %ld %lu %lu %lu",
"%d " TASK_COMM_LEN_FMT " %c %d %d %d %d %d %u %lu %lu %lu %lu "
"%lu %lu %ld %ld %ld %ld %d %d %llu %lu %ld %lu %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->comm,
&s->state,
......@@ -237,7 +238,7 @@ int parse_pid_stat(pid_t pid, int pid_dir, struct proc_pid_stat *s)
&s->end_data,
&s->start_brk);
s->comm[strlen(s->comm) - 1] = '\0'; /* trim the ending ) */
s->comm[TASK_COMM_LEN-1] = '\0';
fclose(f);
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