Commit ea1ec9f6 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

restore: Don't close pstree_fd several times

There is a scenario when pstree_fd may be tried
to close several times -- if we start crtools
with "detach" option.

So simply make restore_root_task to close opened
file descriptor, this also simplifies the code.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 644e4fec
......@@ -1394,13 +1394,13 @@ static int restore_root_task(int fd, struct cr_options *opts)
struct sigaction act, old_act;
ret = read(fd, &e, sizeof(e));
close(fd);
if (ret != sizeof(e)) {
pr_perror("Can't read root pstree entry");
return -1;
}
close(fd);
ret = sigaction(SIGCHLD, NULL, &act);
if (ret < 0) {
perror("sigaction() failed\n");
......@@ -1457,19 +1457,17 @@ static int restore_all_tasks(pid_t pid, struct cr_options *opts)
{
int pstree_fd = -1;
u32 type = 0;
int ret = -1;
pstree_fd = open_image_ro(CR_FD_PSTREE, pstree_pid);
if (pstree_fd < 0)
return -1;
if (prepare_shared(pstree_fd))
goto out;
if (prepare_shared(pstree_fd)) {
close(pstree_fd);
return -1;
}
ret = restore_root_task(pstree_fd, opts);
out:
close_safe(&pstree_fd);
return ret;
return restore_root_task(pstree_fd, opts);
}
static long restorer_get_vma_hint(pid_t pid, struct list_head *self_vma_list, long vma_len)
......
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