mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
rst: Close standard descriptors before fds restore
Strictly speaking we have to close all fds before reopening them from the image. This can be done using not yet merged nextfd syscall, but it's not yet merged :( By now just close std and 255 (bash's) descriptors. This is ugly, but I prefer to wait for the nextfd syscall. But skip the init tasks' stds becase the existing zdtm implementation uses system() in such tasks which doesn't work when all fds are closed. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
21
files.c
21
files.c
@@ -433,12 +433,33 @@ static int open_fdinfo(int pid, struct fdinfo_list_entry *fle, int state)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int close_old_fds(struct pstree_item *me)
|
||||
{
|
||||
/*
|
||||
* FIXME -- The existing test_init implementation uses system()
|
||||
* which in turn doesn't work when all fds are closed
|
||||
*/
|
||||
if (me->pid.virt == 1)
|
||||
return 0;
|
||||
|
||||
/* FIXME -- wait for nextfd syscall (or read proc) */
|
||||
close(0);
|
||||
close(1);
|
||||
close(2);
|
||||
close(255); /* bash */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int prepare_fds(struct pstree_item *me)
|
||||
{
|
||||
u32 ret;
|
||||
int state;
|
||||
struct fdinfo_list_entry *fle;
|
||||
|
||||
ret = close_old_fds(me);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
pr_info("Opening fdinfo-s\n");
|
||||
|
||||
for (state = 0; state < FD_STATE_MAX; state++) {
|
||||
|
Reference in New Issue
Block a user