[PATCH] init: Set the RUNLEVEL environment

Shaun Jackman sjackman at gmail.com
Sat Jul 8 00:48:11 UTC 2006


Busybox's init application does not use the runlevel argument, except
for the special case of single-user mode. This patch passes the
runlevel argument on to the children processes in the environment
variable RUNLEVEL so that they may do something with it. For example,
I have an /etc/rc file that simply calls /etc/rc$RUNLEVEL. This
behaviour matches that of the standard Linux System-V-like init
application. Please apply.

Cheers,
Shaun

2006-07-07  Shaun Jackman  <sjackman at gmail.com>

	* init/init.c (init_main): Set the RUNLEVEL environment.

--- init/init.c	7c1c416e705e9cd6bb4e44a71f0f89ff81ede8cb
+++ init/init.c	0cfeb638397fac566743b7f0228f532d56bc6a11
@@ -1046,6 +1046,9 @@
 		for(e = environment; *e; e++)
  			putenv((char *) *e);
 	}
+	if (argc > 1)
+		setenv("RUNLEVEL", argv[1], 1);
+
 	/* Hello world */
  	message(MAYBE_CONSOLE | LOG, "init started:  %s", bb_msg_full_version);



More information about the busybox mailing list