aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2005-08-01 16:43:13 +0000
committerPaul Fox <pgf@brightstareng.com>2005-08-01 16:43:13 +0000
commit41a72ecd1936bc0b4ae75c723c88129bb01928ff (patch)
treee051b9b4fceba69fb263e28a7275b3feb480d6e7
parent79c142d93847c168b825858f4e372e10c7e32906 (diff)
downloadbusybox-41a72ecd1936bc0b4ae75c723c88129bb01928ff.tar.gz
applying patch from bug 24:
0000024 03-16-05 patch: allow init to set controlling tty
-rw-r--r--init/Config.in11
-rw-r--r--init/init.c7
2 files changed, 18 insertions, 0 deletions
diff --git a/init/Config.in b/init/Config.in
index 521f8fe1d..a3584aaf5 100644
--- a/init/Config.in
+++ b/init/Config.in
@@ -43,6 +43,17 @@ config CONFIG_FEATURE_INIT_SWAPON
If the system has less than one megabyte of total memory, init
will run '/sbin/swapon -a' to add swap memory.
+config CONFIG_FEATURE_INIT_SCTTY
+ bool " Support running commands with a controlling-tty?"
+ default n
+ depends on CONFIG_INIT
+ help
+ If this option is enabled a command starting with hyphen (-)
+ is run in its own session (setsid(2)) and possibly with a
+ controlling tty (TIOCSCTTY). This is not the traditional init
+ behavour, but is often what you want in an embedded system where
+ the console is only accessed during development or for maintenance.
+
config CONFIG_FEATURE_EXTRA_QUIET
bool " Should init be _extra_ quiet on boot?"
default y
diff --git a/init/init.c b/init/init.c
index 8687b106c..0f49a45d8 100644
--- a/init/init.c
+++ b/init/init.c
@@ -577,6 +577,13 @@ static pid_t run(const struct init_action *a)
cmd[0][0] = '-';
strcpy(cmd[0] + 1, s);
}
+#ifdef CONFIG_FEATURE_INIT_SCTTY
+ /* Establish this process as session leader and
+ * (attempt) to make the tty (if any) a controlling tty.
+ */
+ (void) setsid();
+ (void) ioctl(0, TIOCSCTTY, 0/*don't steal it*/);
+#endif
}
#if !defined(__UCLIBC__) || defined(__ARCH_HAS_MMU__)