lxc/0038-make-the-given-terminal-as-controlling-terminal.patch
LiFeng c1c967d9bc lxc: make lxc-libs package
Signed-off-by: LiFeng <lifeng68@huawei.com>
2020-02-14 06:13:22 -05:00

47 lines
1.6 KiB
Diff

From 00b977726fdcf2bbc5e44275db4c7b68ef8fa549 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Tue, 15 Jan 2019 23:24:21 -0500
Subject: [PATCH 038/139] make the given terminal as controlling terminal
Avoid warning when start cmd /bin/sh :
sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
src/lxc/start.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 708ab7f..ec61b32 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1330,7 +1330,15 @@ static int do_start(void *data)
* setup on its console ie. the pty allocated in lxc_terminal_setup() so
* make sure that that pty is stdin,stdout,stderr.
*/
+ setsid();
if (handler->conf->console.slave >= 0) {
+ /* isulad:make the given terminal as controlling terminal to avoid warning
+ * sh: cannot set terminal process group (-1): Inappropriate ioctl for device
+ * sh: no job control in this shell */
+ if (ioctl(handler->conf->console.slave, TIOCSCTTY, NULL) < 0) {
+ ERROR("Faild to make the given terminal the controlling terminal of the calling process");
+ goto out_warn_father;
+ }
if (handler->daemonize || !handler->conf->is_execute)
ret = set_stdfds(handler->conf->console.slave);
else
@@ -1377,8 +1385,6 @@ static int do_start(void *data)
devnull_fd = -1;
}
- setsid();
-
if (handler->conf->init_cwd) {
/* isulad: try to craete workdir if not exist */
struct stat st;
--
1.8.3.1