[CRIU] [PATCH v5 28/33] files: Move ctty fixup to open_fd()
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Dec 26 06:29:33 PST 2016
Fixup ctty right after it's open. It'll need for
merging tty files in single fds list: set ctty
before next fle in list is processed. See next
patch for the details.
v4: New
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/files.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/criu/files.c b/criu/files.c
index c8a9cae99..26ff5a90c 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1022,9 +1022,7 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
ret = receive_fd(pid, fle);
if (ret != 0)
return ret;
-
- fle->stage = FLE_RESTORED;
- return 0;
+ goto fixup_ctty;
}
ret = d->ops->open(d, &new_fd);
@@ -1032,9 +1030,16 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
if (setup_and_serve_out(fle, new_fd) < 0)
return -1;
}
+fixup_ctty:
+ if (ret == 0) {
+ if (fle->fe->fd == get_service_fd(CTL_TTY_OFF)) {
+ ret = tty_restore_ctl_terminal(fle->desc, fle->fe->fd);
+ if (ret == -1)
+ return ret;
+ }
- if (ret == 0)
fle->stage = FLE_RESTORED;
+ }
return ret;
}
@@ -1061,7 +1066,7 @@ static int receive_fd(int pid, struct fdinfo_list_entry *fle)
static int open_fdinfos(int pid, struct list_head *list)
{
- struct fdinfo_list_entry *fle, *tmp, *service_fle = NULL;
+ struct fdinfo_list_entry *fle, *tmp;
LIST_HEAD(completed);
bool progress, again;
int st, ret = 0;
@@ -1089,8 +1094,6 @@ static int open_fdinfos(int pid, struct list_head *list)
}
if (ret == 1)
again = true;
- if (fle->fe->fd == get_service_fd(CTL_TTY_OFF))
- service_fle = fle;
}
if (!progress && again)
wait_fds_event();
@@ -1100,9 +1103,6 @@ static int open_fdinfos(int pid, struct list_head *list)
splice:
list_splice(&completed, list);
- if (ret == 0 && service_fle)
- ret = tty_restore_ctl_terminal(service_fle->desc, service_fle->fe->fd);
-
return ret;
}
More information about the CRIU
mailing list