mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
tty: Use separate tty_info::inherit member to track ttys being borrowed from a parent
This is easier for debugging, the former SID/PGID remains untouched and printed out in logs. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
9c5817391d
commit
19de6865c4
14
tty.c
14
tty.c
@@ -80,6 +80,7 @@ struct tty_info {
|
|||||||
int major;
|
int major;
|
||||||
|
|
||||||
bool create;
|
bool create;
|
||||||
|
bool inherit;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tty_dump_info {
|
struct tty_dump_info {
|
||||||
@@ -95,8 +96,6 @@ struct tty_dump_info {
|
|||||||
static LIST_HEAD(all_tty_info_entries);
|
static LIST_HEAD(all_tty_info_entries);
|
||||||
static LIST_HEAD(all_ttys);
|
static LIST_HEAD(all_ttys);
|
||||||
|
|
||||||
#define INHERIT_SID (-1)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Usually an application has not that many ttys opened.
|
* Usually an application has not that many ttys opened.
|
||||||
* If this won't be enough in future we simply need to
|
* If this won't be enough in future we simply need to
|
||||||
@@ -411,9 +410,9 @@ static bool tty_has_active_pair(struct tty_info *info)
|
|||||||
|
|
||||||
static void tty_show_pty_info(char *prefix, struct tty_info *info)
|
static void tty_show_pty_info(char *prefix, struct tty_info *info)
|
||||||
{
|
{
|
||||||
pr_info("%s type %s id %#x index %d (master %d sid %d pgrp %d)\n",
|
pr_info("%s type %s id %#x index %d (master %d sid %d pgrp %d inherit %d)\n",
|
||||||
prefix, tty_type(info->major), info->tfe->id, info->tie->pty->index,
|
prefix, tty_type(info->major), info->tfe->id, info->tie->pty->index,
|
||||||
pty_is_master(info), info->tie->sid, info->tie->pgrp);
|
pty_is_master(info), info->tie->sid, info->tie->pgrp, info->inherit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int restore_tty_params(int fd, struct tty_info *info)
|
static int restore_tty_params(int fd, struct tty_info *info)
|
||||||
@@ -535,7 +534,7 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
|
|||||||
* be inherited, either it requires a fake master.
|
* be inherited, either it requires a fake master.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (likely(slave->tie->sid == INHERIT_SID)) {
|
if (likely(slave->inherit)) {
|
||||||
fd = dup(get_service_fd(SELF_STDIN_OFF));
|
fd = dup(get_service_fd(SELF_STDIN_OFF));
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
pr_perror("Can't dup SELF_STDIN_OFF");
|
pr_perror("Can't dup SELF_STDIN_OFF");
|
||||||
@@ -577,7 +576,7 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
|
|||||||
* be already restored properly thus we can simply
|
* be already restored properly thus we can simply
|
||||||
* use syscalls instead of lookup via process tree.
|
* use syscalls instead of lookup via process tree.
|
||||||
*/
|
*/
|
||||||
if (likely(slave->tie->sid == INHERIT_SID)) {
|
if (likely(slave->inherit)) {
|
||||||
if (tty_set_prgp(fd, getpgid(getppid())))
|
if (tty_set_prgp(fd, getpgid(getppid())))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -763,7 +762,7 @@ static int tty_find_restoring_task(struct tty_info *info)
|
|||||||
shell_job:
|
shell_job:
|
||||||
if (opts.shell_job) {
|
if (opts.shell_job) {
|
||||||
pr_info("Inherit terminal for id %x\n", info->tfe->id);
|
pr_info("Inherit terminal for id %x\n", info->tfe->id);
|
||||||
info->tie->sid = info->tie->pgrp = INHERIT_SID;
|
info->inherit = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -944,6 +943,7 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg)
|
|||||||
INIT_LIST_HEAD(&info->sibling);
|
INIT_LIST_HEAD(&info->sibling);
|
||||||
info->major = major(info->tie->rdev);
|
info->major = major(info->tie->rdev);
|
||||||
info->create = (info->major == TTYAUX_MAJOR);
|
info->create = (info->major == TTYAUX_MAJOR);
|
||||||
|
info->inherit = false;
|
||||||
|
|
||||||
if (verify_info(info))
|
if (verify_info(info))
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user