criu/include/tty.h
Cyrill Gorcunov f0606bc8d9 tty: Introduce deferred checking of tty sids
The dumping of tty peers is somewhat tricky. And it became more
complex once we allowed to migrate/inherit sessions.

It's being found (in screen c/r) that we've a problem in looking
up of session leaders while dumping tty.

Let me explain with more details. Here is an example of screen
session

  PID   GID   SID
20567 20567 20567           SCREEN
20568 20568 20568  pts/3     \_ /bin/bash

The screen opens master peer (ptmx) and then provides
bash the slave peer (pts/3) where bash sets up a session
leader on it.

Thus we get interesting scenario -- our pstree construction
is done in lazy fashion, we run parasite code to fetch sid/pgid
of a process tree item only when we're really dumping the task.

Thus when we start dumping ptmx peer (which belongs to SCREEN)
we've not yet constructed the process tree item for children
(ie /bin/bash) and the lookup function in tty code (which walks
over all process items in a tree) simply fails to find sid of
child, because we've not yet dumped it.

Thus, to resolve such situation we verify tty sids at late stage
of dumping.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:34 +04:00

27 lines
587 B
C

#ifndef CR_TTY_H__
#define CR_TTY_H__
#include "files.h"
#include "crtools.h"
/* Kernel's limit */
#define TERMIOS_NCC 19
#define PTMX_PATH "/dev/ptmx"
#ifndef PTMX_MINOR
# define PTMX_MINOR 2
#endif
#define PTS_FMT "/dev/pts/%d"
extern int dump_tty(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_verify_tty_sids(void);
extern int collect_tty(void);
extern int prepare_shared_tty(void);
extern int tty_setup_slavery(void);
extern int tty_verify_active_pairs(void);
extern int tty_prep_fds(void);
extern void tty_fini_fds(void);
#endif /* CR_TTY_H__ */