init fails to compile for !CONFIG_FEATURE_KILL_REMOVED

Denys Vlasenko vda.linux at googlemail.com
Sat Feb 14 20:58:20 UTC 2009


On Saturday 14 February 2009 14:02, Bernhard Reutner-Fischer wrote:
> Hi,
> 
> When CONFIG_FEATURE_KILL_REMOVED is off then we end up with
> 
> $ egrep "(INIT|KILL)" .config
> CONFIG_INIT=y
> CONFIG_FEATURE_USE_INITTAB=y
> # CONFIG_FEATURE_KILL_REMOVED is not set
> CONFIG_FEATURE_KILL_DELAY=
> CONFIG_FEATURE_INIT_SCTTY=y
> CONFIG_FEATURE_INIT_SYSLOG=y
> CONFIG_FEATURE_INIT_COREDUMPS=y
> CONFIG_FEATURE_INITRD=y
> CONFIG_KILL=y
> CONFIG_KILLALL=y
> CONFIG_KILLALL5=y
> CONFIG_PKILL=y
> 
> That KILL_DELAY does no good for this spot:
> 
> Index: init/init.c
> ===================================================================
> --- init/init.c	(revision 25330)
> +++ init/init.c	(working copy)
> - improve helptext
> @@ -788,10 +788,13 @@ static void reload_inittab(void)
>  		for (a = init_action_list; a; a = a->next)
>  			if (a->action_type == ONCE && a->pid != 0)
>  				kill(a->pid, SIGTERM);
> -		if (CONFIG_FEATURE_KILL_DELAY) {
> +		if (ENABLE_FEATURE_KILL_DELAY) {
>  			/* NB: parent will wait in NOMMU case */
>  			if ((BB_MMU ? fork() : vfork()) == 0) { /* child */
> -				sleep(CONFIG_FEATURE_KILL_DELAY);
> +#if !ENABLE_FEATURE_KILL_REMOVED && ENABLE_FEATURE_KILL_DELAY
> +#define CONFIG_FEATURE_KILL_DELAY_SECS 0 /* logic goof w/ kconfig */
> +#endif
> +				sleep(CONFIG_FEATURE_KILL_DELAY_SECS);
>  				for (a = init_action_list; a; a = a->next)
>  					if (a->action_type == ONCE && a->pid != 0)
>  						kill(a->pid, SIGKILL);
> 
> This should work but doesn't sound too clean. Suggestions?

Hmm, there goes my attempt to make Rob happier :)
(he wanted less #if's in init.c).

This is the case when #if is better than if
(because #if would work, and if won't):

--- init/init.c	(revision 25310)
+++ init/init.c	(working copy)
@@ -782,23 +782,23 @@
 	 */
 	parse_inittab();
 
-	if (ENABLE_FEATURE_KILL_REMOVED) {
-		/* Kill stale entries */
-		/* Be nice and send SIGTERM first */
-		for (a = init_action_list; a; a = a->next)
-			if (a->action_type == ONCE && a->pid != 0)
-				kill(a->pid, SIGTERM);
-		if (CONFIG_FEATURE_KILL_DELAY) {
-			/* NB: parent will wait in NOMMU case */
-			if ((BB_MMU ? fork() : vfork()) == 0) { /* child */
-				sleep(CONFIG_FEATURE_KILL_DELAY);
-				for (a = init_action_list; a; a = a->next)
-					if (a->action_type == ONCE && a->pid != 0)
-						kill(a->pid, SIGKILL);
-				_exit(EXIT_SUCCESS);
-			}
+#if ENABLE_FEATURE_KILL_REMOVED
+	/* Kill stale entries */
+	/* Be nice and send SIGTERM first */
+	for (a = init_action_list; a; a = a->next)
+		if (a->action_type == ONCE && a->pid != 0)
+			kill(a->pid, SIGTERM);
+	if (CONFIG_FEATURE_KILL_DELAY) {
+		/* NB: parent will wait in NOMMU case */
+		if ((BB_MMU ? fork() : vfork()) == 0) { /* child */
+			sleep(CONFIG_FEATURE_KILL_DELAY);
+			for (a = init_action_list; a; a = a->next)
+				if (a->action_type == ONCE && a->pid != 0)
+					kill(a->pid, SIGKILL);
+			_exit(EXIT_SUCCESS);
 		}
 	}
+#endif
 
 	/* Remove stale (ONCE) and not useful (SYSINIT,WAIT) entries */
 	nextp = &init_action_list;

--
vda


More information about the busybox mailing list