[BusyBox-cvs] svn commit: trunk/busybox/init

pgf at busybox.net pgf at busybox.net
Mon Aug 1 16:43:14 UTC 2005


Author: pgf
Date: 2005-08-01 10:43:13 -0600 (Mon, 01 Aug 2005)
New Revision: 11007

Log:
applying patch from bug 24:
    0000024 03-16-05 patch: allow init to set controlling tty



Modified:
   trunk/busybox/init/Config.in
   trunk/busybox/init/init.c


Changeset:
Modified: trunk/busybox/init/Config.in
===================================================================
--- trunk/busybox/init/Config.in	2005-08-01 16:04:40 UTC (rev 11006)
+++ trunk/busybox/init/Config.in	2005-08-01 16:43:13 UTC (rev 11007)
@@ -43,6 +43,17 @@
 	  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

Modified: trunk/busybox/init/init.c
===================================================================
--- trunk/busybox/init/init.c	2005-08-01 16:04:40 UTC (rev 11006)
+++ trunk/busybox/init/init.c	2005-08-01 16:43:13 UTC (rev 11007)
@@ -577,6 +577,13 @@
 				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__)




More information about the busybox-cvs mailing list