[CRIU] [PATCH v2] tty: Restore controlling terminal once per session

Cyrill Gorcunov gorcunov at gmail.com
Mon Nov 9 14:45:15 PST 2015


On Mon, Nov 09, 2015 at 08:10:53PM +0300, Cyrill Gorcunov wrote:
> On Mon, Nov 09, 2015 at 08:04:29PM +0300, Pavel Emelyanov wrote:
> > 
> > Hm... What if I open /dev/ptmx and then two (or more) /dev/pts/X ? Would
> > the same problem arise?
> 
> I think yes.

You know, for pts we've a workaround already :)

tty_find_restoring_task
	...
	if (info->tie->sid) {
		if (!tty_is_master(info)) {
			if (tty_has_active_pair(info))

here, if we get fd which has opened pts, we simply ignore it,
because we're restoring controlling terminal via fake slave
(see below)

				return 0;
			else
				goto shell_job;
		}

static int tty_restore_ctl_terminal(struct file_desc *d, int fd)
	...
	if (is_pty(info->driver)) {
		...
		fake = pty_alloc_fake_slave(info);
		...
	}

IOW, for pty devices we have multiple instance of fd properly
handled, but this doesn't apply to VT devices and probably
any other in future.

	Cyrill


More information about the CRIU mailing list