From: Christian Brauner Date: Sat, 30 Jun 2018 11:06:08 +0000 (+0200) Subject: terminal: set FD_CLOEXEC on pty file descriptors X-Git-Tag: lxc-3.1.0~224^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=408c18a185b17e9a3099e20a2d1d74742df03811;p=thirdparty%2Flxc.git terminal: set FD_CLOEXEC on pty file descriptors Signed-off-by: Christian Brauner Cc: Wolfgang Bumiller --- diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c index 338d33cd4..bc61d4e5f 100644 --- a/src/lxc/terminal.c +++ b/src/lxc/terminal.c @@ -584,6 +584,18 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal, goto on_error; } + ret = fd_cloexec(terminal->proxy.master, true); + if (ret < 0) { + SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal master"); + goto on_error; + } + + ret = fd_cloexec(terminal->proxy.slave, true); + if (ret < 0) { + SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal slave"); + goto on_error; + } + ret = lxc_setup_tios(terminal->proxy.slave, &oldtermio); if (ret < 0) goto on_error; @@ -881,13 +893,13 @@ int lxc_terminal_create(struct lxc_terminal *terminal) goto err; } - ret = fcntl(terminal->master, F_SETFD, FD_CLOEXEC); + ret = fd_cloexec(terminal->master, true); if (ret < 0) { SYSERROR("Failed to set FD_CLOEXEC flag on terminal master"); goto err; } - ret = fcntl(terminal->slave, F_SETFD, FD_CLOEXEC); + ret = fd_cloexec(terminal->slave, true); if (ret < 0) { SYSERROR("Failed to set FD_CLOEXEC flag on terminal slave"); goto err;