Skip to content

Commit

Permalink
tty: Only store the stdin fd when it corresponds to a tty
Browse files Browse the repository at this point in the history
Doing otherwise can lead to problems when using inherit-fd on stdin as
it gets closed.

Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
  • Loading branch information
nviennot committed Apr 23, 2021
1 parent f1cc40c commit e4c6af2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions criu/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -2342,13 +2342,14 @@ int tty_prep_fds(void)

if (!isatty(STDIN_FILENO))
pr_info("Standard stream is not a terminal, may fail later\n");
else
else {
stdin_isatty = true;

self_stdin_fdid = fdstore_add(STDIN_FILENO);
if (self_stdin_fdid < 0) {
pr_err("Can't place stdin fd to fdstore\n");
return -1;
self_stdin_fdid = fdstore_add(STDIN_FILENO);
if (self_stdin_fdid < 0) {
pr_err("Can't place stdin fd to fdstore\n");
return -1;
}
}

return 0;
Expand Down

0 comments on commit e4c6af2

Please sign in to comment.