diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h index 0d79f1346..3264e923f 100644 --- a/compel/include/uapi/infect.h +++ b/compel/include/uapi/infect.h @@ -24,8 +24,9 @@ struct seize_task_status { }; extern int compel_wait_task(int pid, int ppid, - int (*get_status)(int pid, struct seize_task_status *), - struct seize_task_status *st); + int (*get_status)(int pid, struct seize_task_status *, void *data), + void (*free_status)(int pid, struct seize_task_status *, void *data), + struct seize_task_status *st, void *data); extern int compel_stop_task(int pid); extern int compel_resume_task(pid_t pid, int orig_state, int state); diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c index 7f6d2f3f1..07200a7a6 100644 --- a/compel/src/lib/infect.c +++ b/compel/src/lib/infect.c @@ -52,7 +52,7 @@ static inline void close_safe(int *pfd) } } -static int parse_pid_status(int pid, struct seize_task_status *ss) +static int parse_pid_status(int pid, struct seize_task_status *ss, void *data) { char aux[128]; FILE *f; @@ -107,7 +107,7 @@ int compel_stop_task(int pid) ret = compel_interrupt_task(pid); if (ret == 0) - ret = compel_wait_task(pid, -1, parse_pid_status, &ss); + ret = compel_wait_task(pid, -1, parse_pid_status, NULL, &ss, NULL); return ret; } @@ -192,8 +192,9 @@ static int skip_sigstop(int pid, int nr_signals) * up with someone else. */ int compel_wait_task(int pid, int ppid, - int (*get_status)(int pid, struct seize_task_status *), - struct seize_task_status *ss) + int (*get_status)(int pid, struct seize_task_status *, void *), + void (*free_status)(int pid, struct seize_task_status *, void *), + struct seize_task_status *ss, void *data) { siginfo_t si; int status, nr_sigstop; @@ -220,7 +221,7 @@ try_again: wait_errno = errno; } - ret2 = get_status(pid, ss); + ret2 = get_status(pid, ss, data); if (ret2) goto err; @@ -271,6 +272,8 @@ try_again: } ret = 0; + if (free_status) + free_status(pid, ss, data); goto try_again; } diff --git a/criu/include/proc_parse.h b/criu/include/proc_parse.h index d67ac5e56..5538757f9 100644 --- a/criu/include/proc_parse.h +++ b/criu/include/proc_parse.h @@ -96,7 +96,7 @@ extern int parse_pid_stat(pid_t pid, struct proc_pid_stat *s); extern unsigned int parse_pid_loginuid(pid_t pid, int *err, bool ignore_noent); extern int parse_pid_oom_score_adj(pid_t pid, int *err); extern int prepare_loginuid(unsigned int value, unsigned int loglevel); -extern int parse_pid_status(pid_t pid, struct seize_task_status *); +extern int parse_pid_status(pid_t pid, struct seize_task_status *, void *data); extern int parse_file_locks(void); extern int get_fd_mntid(int fd, int *mnt_id); diff --git a/criu/proc_parse.c b/criu/proc_parse.c index 19a010e7f..f1237cf9f 100644 --- a/criu/proc_parse.c +++ b/criu/proc_parse.c @@ -993,7 +993,7 @@ static int cap_parse(char *str, unsigned int *res) return 0; } -int parse_pid_status(pid_t pid, struct seize_task_status *ss) +int parse_pid_status(pid_t pid, struct seize_task_status *ss, void *data) { struct proc_status_creds *cr = container_of(ss, struct proc_status_creds, s); struct bfd f; diff --git a/criu/seize.c b/criu/seize.c index 064b4a8ec..ae99ddf56 100644 --- a/criu/seize.c +++ b/criu/seize.c @@ -490,7 +490,7 @@ static int collect_children(struct pstree_item *item) goto free; } - ret = compel_wait_task(pid, item->pid->real, parse_pid_status, &creds->s); + ret = compel_wait_task(pid, item->pid->real, parse_pid_status, NULL, &creds->s, NULL); if (ret < 0) { /* * Here is a race window between parse_children() and seize(), @@ -716,7 +716,7 @@ static int collect_threads(struct pstree_item *item) if (!opts.freeze_cgroup && compel_interrupt_task(pid)) continue; - ret = compel_wait_task(pid, item_ppid(item), parse_pid_status, &t_creds.s); + ret = compel_wait_task(pid, item_ppid(item), parse_pid_status, NULL, &t_creds.s, NULL); if (ret < 0) { /* * Here is a race window between parse_threads() and seize(), @@ -855,7 +855,7 @@ int collect_pstree(void) if (!creds) goto err; - ret = compel_wait_task(pid, -1, parse_pid_status, &creds->s); + ret = compel_wait_task(pid, -1, parse_pid_status, NULL, &creds->s, NULL); if (ret < 0) goto err;