Commit f139581a authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

files: Move ctty fixup to open_fd()

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: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 3432e989
......@@ -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;
}
/*
......@@ -1045,9 +1043,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;
}
......@@ -1074,7 +1079,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;
......@@ -1102,8 +1107,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();
......@@ -1113,9 +1116,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;
}
......
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