diff -Naur busybox.orig/runit/Config.in busybox/runit/Config.in
--- busybox.orig/runit/Config.in	2008-09-04 19:44:11 +0000
+++ busybox/runit/Config.in	2008-09-19 20:41:05 +0000
@@ -20,6 +20,13 @@
 	  a directory, in the services directory dir, up to a limit of 1000
 	  subdirectories, and restarts a runsv process if it terminates.
 
+config FEATURE_RUNSVDIR_LOG
+	bool "Enable logging"
+	depends on RUNSVDIR
+	default y
+	help
+	  Enable periodical timestamp logging.
+
 config SV
 	bool "sv"
 	default n
diff -Naur busybox.orig/runit/runsvdir.c busybox/runit/runsvdir.c
--- busybox.orig/runit/runsvdir.c	2008-09-12 18:59:08 +0000
+++ busybox/runit/runsvdir.c	2008-09-19 20:29:20 +0000
@@ -35,34 +35,36 @@
 
 #define MAXSERVICES 1000
 
-struct service {
+typedef struct service {
 	dev_t dev;
 	ino_t ino;
 	pid_t pid;
 	smallint isgone;
-};
+} service_t;
 
 struct globals {
-	struct service *sv;
+	llist_t *services;
 	char *svdir;
+USE_FEATURE_RUNSVDIR_LOG (
 	char *rplog;
-	int svnum;
 	int rploglen;
 	struct fd_pair logpipe;
-	struct pollfd pfd[1];
+	struct pollfd pfd;
 	unsigned stamplog;
+)
 	smallint check; /* = 1; */
 	smallint set_pgrp;
 };
 #define G (*(struct globals*)&bb_common_bufsiz1)
-#define sv        (G.sv        )
+#define services  (G.services  )
 #define svdir     (G.svdir     )
-#define rplog     (G.rplog     )
-#define svnum     (G.svnum     )
-#define rploglen  (G.rploglen  )
-#define logpipe   (G.logpipe   )
-#define pfd       (G.pfd       )
-#define stamplog  (G.stamplog  )
+USE_FEATURE_RUNSVDIR_LOG (
+#	define rplog     (G.rplog     )
+#	define rploglen  (G.rploglen  )
+#	define logpipe   (G.logpipe   )
+#	define pfd       (G.pfd       )
+#	define stamplog  (G.stamplog  )
+)
 #define check     (G.check     )
 #define set_pgrp  (G.set_pgrp  )
 #define INIT_G() do { \
@@ -82,21 +84,15 @@
 {
 	warn3x("cannot ", m1, m2);
 }
+#if ENABLE_FEATURE_RUNSVDIR_LOG
 static void warnx(const char *m1)
 {
 	warn3x(m1, "", "");
 }
-
-static void runsv(int no, const char *name)
+#endif
+static void runsv(service_t *srv, const char *name)
 {
-	pid_t pid;
-	char *prog[3];
-
-	prog[0] = (char*)"runsv";
-	prog[1] = (char*)name;
-	prog[2] = NULL;
-
-	pid = vfork();
+	pid_t pid = vfork();
 
 	if (pid == -1) {
 		warn2_cannot("vfork", "");
@@ -110,17 +106,20 @@
 			+ (1 << SIGHUP)
 			+ (1 << SIGTERM)
 			, SIG_DFL);
-		execvp(prog[0], prog);
+		execlp("runsv", "runsv", name, NULL);
 		fatal2_cannot("start runsv ", name);
 	}
-	sv[no].pid = pid;
+	srv->pid = pid;
 }
 
+#define FOR_EACH_SERVICE for (srv = services; srv; srv = srv->link)
+#define SRV ((service_t *)(srv->data))
+
 static void runsvdir(void)
 {
 	DIR *dir;
 	direntry *d;
-	int i;
+	llist_t *srv;
 	struct stat s;
 
 	dir = opendir(".");
@@ -128,8 +127,8 @@
 		warn2_cannot("open directory ", svdir);
 		return;
 	}
-	for (i = 0; i < svnum; i++)
-		sv[i].isgone = 1;
+	FOR_EACH_SERVICE
+		SRV->isgone = 1;
 
 	while (1) {
 		errno = 0;
@@ -145,30 +144,29 @@
 		}
 		if (!S_ISDIR(s.st_mode))
 			continue;
-		for (i = 0; i < svnum; i++) {
-			if ((sv[i].ino == s.st_ino) && (sv[i].dev == s.st_dev)) {
-				sv[i].isgone = 0;
-				if (!sv[i].pid)
-					runsv(i, d->d_name);
+		FOR_EACH_SERVICE {
+			if ((SRV->ino == s.st_ino) && (SRV->dev == s.st_dev)) {
+				SRV->isgone = 0;
+				if (!SRV->pid)
+					runsv(SRV, d->d_name);
 				break;
 			}
 		}
-		if (i == svnum) {
+		if (!srv) {
 			/* new service */
-			struct service *svnew = realloc(sv, (i+1) * sizeof(*sv));
-			if (!svnew) {
+			service_t *sv = malloc(sizeof(service_t));
+			memset(sv, 0, sizeof(service_t));
+			if (!sv) {
 				warn3x("cannot start runsv ", d->d_name,
 						" too many services");
 				continue;
 			}
-			sv = svnew;
-			svnum++;
-			memset(&sv[i], 0, sizeof(sv[i]));
-			sv[i].ino = s.st_ino;
-			sv[i].dev = s.st_dev;
-			/*sv[i].pid = 0;*/
-			/*sv[i].isgone = 0;*/
-			runsv(i, d->d_name);
+			llist_add_to(&services, sv);
+			sv->ino = s.st_ino;
+			sv->dev = s.st_dev;
+			/*sv->pid = 0;*/
+			/*sv->isgone = 0;*/
+			runsv(sv, d->d_name);
 			check = 1;
 		}
 	}
@@ -181,40 +179,18 @@
 	closedir(dir);
 
 	/* SIGTERM removed runsv's */
-	for (i = 0; i < svnum; i++) {
-		if (!sv[i].isgone)
-			continue;
-		if (sv[i].pid)
-			kill(sv[i].pid, SIGTERM);
-		sv[i] = sv[--svnum];
-/* BUG? we deleted sv[i] by copying over sv[last], but we will not check this newly-copied one! */
-		check = 1;
-	}
-}
-
-static int setup_log(void)
-{
-	rploglen = strlen(rplog);
-	if (rploglen < 7) {
-		warnx("log must have at least seven characters");
-		return 0;
-	}
-	if (piped_pair(logpipe)) {
-		warnx("cannot create pipe for log");
-		return -1;
-	}
-	close_on_exec_on(logpipe.rd);
-	close_on_exec_on(logpipe.wr);
-	ndelay_on(logpipe.rd);
-	ndelay_on(logpipe.wr);
-	if (dup2(logpipe.wr, 2) == -1) {
-		warnx("cannot set filedescriptor for log");
-		return -1;
+	srv = services;
+	while (srv) {
+		if (SRV->isgone) {
+			if (SRV->pid)
+				kill(SRV->pid, SIGTERM);
+			llist_unlink(&services, srv);
+			free(SRV); // free service_t*
+			free(srv); // free llist_t*
+			check = 1;
+		} else
+			srv = srv->link;
 	}
-	pfd[0].fd = logpipe.rd;
-	pfd[0].events = POLLIN;
-	stamplog = monotonic_sec();
-	return 1;
 }
 
 int runsvdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -230,8 +206,7 @@
 	unsigned deadline;
 	unsigned now;
 	unsigned stampcheck;
-	char ch;
-	int i;
+	llist_t *srv;
 
 	INIT_G();
 
@@ -241,13 +216,36 @@
 
 	bb_signals_recursive((1 << SIGTERM) | (1 << SIGHUP), record_signo);
 	svdir = *argv++;
-	if (argv && *argv) {
+
+#if ENABLE_FEATURE_RUNSVDIR_LOG
+	/* setup log */
+	if (argv[0] && argv[0][0]) {
 		rplog = *argv;
-		if (setup_log() != 1) {
-			rplog = 0;
-			warnx("log service disabled");
+		rploglen = strlen(rplog);
+		if (rploglen < 7) {
+			warnx("log must have at least seven characters");
+		} else if (piped_pair(logpipe)) {
+			warnx("cannot create pipe for log");
+		} else {
+			close_on_exec_on(logpipe.rd);
+			close_on_exec_on(logpipe.wr);
+			ndelay_on(logpipe.rd);
+			ndelay_on(logpipe.wr);
+			if (dup2(logpipe.wr, 2) == -1) {
+				warnx("cannot set filedescriptor for log");
+			} else {
+				pfd.fd = logpipe.rd;
+				pfd.events = POLLIN;
+				stamplog = monotonic_sec();
+				goto run;
+			}
 		}
+		rplog = 0;
+		warnx("log service disabled");
 	}
+run:
+#endif
+
 	curdir = open_read(".");
 	if (curdir == -1)
 		fatal2_cannot("open current directory", "");
@@ -255,16 +253,16 @@
 
 	stampcheck = monotonic_sec();
 
-	for (;;) {
+	while (1) {
 		/* collect children */
-		for (;;) {
+		while (1) {
 			pid = wait_any_nohang(&wstat);
 			if (pid <= 0)
 				break;
-			for (i = 0; i < svnum; i++) {
-				if (pid == sv[i].pid) {
+			FOR_EACH_SERVICE {
+				if (pid == SRV->pid) {
 					/* runsv has gone */
-					sv[i].pid = 0;
+					SRV->pid = 0;
 					check = 1;
 					break;
 				}
@@ -300,6 +298,7 @@
 				warn2_cannot("stat ", svdir);
 		}
 
+#if ENABLE_FEATURE_RUNSVDIR_LOG
 		if (rplog) {
 			if ((int)(now - stamplog) >= 0) {
 				write(logpipe.wr, ".", 1);
@@ -307,30 +306,37 @@
 			}
 		}
 
-		pfd[0].revents = 0;
+		pfd.revents = 0;
+#endif
 		sig_block(SIGCHLD);
 		deadline = (check ? 1 : 5);
+#if ENABLE_FEATURE_RUNSVDIR_LOG
 		if (rplog)
-			poll(pfd, 1, deadline*1000);
+			poll(&pfd, 1, deadline*1000);
 		else
+#endif
 			sleep(deadline);
 		sig_unblock(SIGCHLD);
 
-		if (pfd[0].revents & POLLIN) {
+#if ENABLE_FEATURE_RUNSVDIR_LOG
+		if (pfd.revents & POLLIN) {
+			char ch;
 			while (read(logpipe.rd, &ch, 1) > 0) {
 				if (ch) {
+					int i;
 					for (i = 6; i < rploglen; i++)
 						rplog[i-1] = rplog[i];
 					rplog[rploglen-1] = ch;
 				}
 			}
 		}
+#endif
 
 		switch (bb_got_signal) {
 		case SIGHUP:
-			for (i = 0; i < svnum; i++)
-				if (sv[i].pid)
-					kill(sv[i].pid, SIGTERM);
+			FOR_EACH_SERVICE
+				if (SRV->pid)
+					kill(SRV->pid, SIGTERM);
 			// N.B. fall through
 		case SIGTERM:
 			_exit((SIGHUP == bb_got_signal) ? 111 : EXIT_SUCCESS);
