[CRIU] Standard stream is not terminal

Cyrill Gorcunov gorcunov at gmail.com
Mon Sep 1 08:57:11 PDT 2014


On Mon, Sep 01, 2014 at 07:52:48PM +0400, Cyrill Gorcunov wrote:
> 
> Thus no, there is no other option at the moment, you need to provide
> us real tty which we could reuse. Probably we could do a trick --
> defer determination if stdio is tty until we really need it.
> 
> I'm not really sure how criu is integrated into startup service,
> Sanidhya mind to provide more details please?

Here is a patch, which I don't tested at all.

	Cyrill
-------------- next part --------------
diff --git a/tty.c b/tty.c
index 6d351cde991e..0983419e3513 100644
--- a/tty.c
+++ b/tty.c
@@ -529,6 +529,7 @@ static int receive_tty(struct tty_info *info)
 static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
 {
 	int master = -1, ret = -1, fd = -1;
+	static int isatty_tested = 0;
 
 	/*
 	 * We may have 2 cases here: the slave either need to
@@ -536,6 +537,16 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
 	 */
 
 	if (likely(slave->inherit)) {
+		/*
+		 * Defer testing STDIN until really needed.
+		 */
+		if (!isatty_tested) {
+			isatty_tested = 1;
+			if (!isatty(get_service_fd(SELF_STDIN_OFF))) {
+				pr_err("Standard stream is not a terminal, aborting\n");
+				return -1;
+			}
+		}
 		fd = dup(get_service_fd(SELF_STDIN_OFF));
 		if (fd < 0) {
 			pr_perror("Can't dup SELF_STDIN_OFF");
@@ -1214,11 +1225,6 @@ int tty_prep_fds(void)
 	if (!opts.shell_job)
 		return 0;
 
-	if (!isatty(STDIN_FILENO)) {
-		pr_err("Standard stream is not a terminal, aborting\n");
-		return -1;
-	}
-
 	if (install_service_fd(SELF_STDIN_OFF, STDIN_FILENO) < 0) {
 		pr_perror("Can't dup stdin to SELF_STDIN_OFF");
 		return -1;


More information about the CRIU mailing list