mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
Move seize related functions into seize.[ch]
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
47
util.c
47
util.c
@@ -187,53 +187,6 @@ void printk_vma(struct vma_area *vma_area)
|
||||
((vma_area->vma.status & VMA_AREA_VDSO) ? "vdso" : "n")))));
|
||||
}
|
||||
|
||||
int unseize_task(pid_t pid)
|
||||
{
|
||||
return ptrace(PTRACE_DETACH, pid, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine seizes task putting it into a special
|
||||
* state where we can manipulate the task via ptrace
|
||||
* inteface, and finally we can detach ptrace out of
|
||||
* of it so the task would not know if it was saddled
|
||||
* up with someone else.
|
||||
*/
|
||||
int seize_task(pid_t pid)
|
||||
{
|
||||
siginfo_t si;
|
||||
int status;
|
||||
int ret = 0;
|
||||
|
||||
jerr_rc(ptrace(PTRACE_SEIZE, pid, NULL,
|
||||
(void *)(unsigned long)PTRACE_SEIZE_DEVEL), ret, err);
|
||||
jerr_rc(ptrace(PTRACE_INTERRUPT, pid, NULL, NULL), ret, err);
|
||||
|
||||
ret = -10;
|
||||
if (wait4(pid, &status, __WALL, NULL) != pid)
|
||||
goto err;
|
||||
|
||||
ret = -20;
|
||||
if (!WIFSTOPPED(status))
|
||||
goto err;
|
||||
|
||||
jerr_rc(ptrace(PTRACE_GETSIGINFO, pid, NULL, &si), ret, err_cont);
|
||||
|
||||
ret = -30;
|
||||
if ((si.si_code >> 8) != PTRACE_EVENT_STOP)
|
||||
goto err_cont;
|
||||
|
||||
jerr_rc(ptrace(PTRACE_SETOPTIONS, pid, NULL,
|
||||
(void *)(unsigned long)PTRACE_O_TRACEEXIT), ret, err_cont);
|
||||
|
||||
err:
|
||||
return ret;
|
||||
|
||||
err_cont:
|
||||
continue_task(pid);
|
||||
goto err;
|
||||
}
|
||||
|
||||
int close_safe(int *fd)
|
||||
{
|
||||
int ret = 0;
|
||||
|
Reference in New Issue
Block a user