mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 07:15:31 +00:00
crtools: Fix command line parsing in parse_pid_stat
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
@@ -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)
|
|||||||
|
|
||||||
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)
|
|||||||
&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;
|
||||||
|
Reference in New Issue
Block a user