[launchd-changes] [23194] trunk/launchd/src/SystemStarter.c

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 29 20:11:46 PDT 2007


Revision: 23194
          http://trac.macosforge.org/projects/launchd/changeset/23194
Author:   zarzycki at apple.com
Date:     2007-03-29 20:11:46 -0700 (Thu, 29 Mar 2007)

Log Message:
-----------
Simplification.

Modified Paths:
--------------
    trunk/launchd/src/SystemStarter.c

Modified: trunk/launchd/src/SystemStarter.c
===================================================================
--- trunk/launchd/src/SystemStarter.c	2007-03-30 02:54:51 UTC (rev 23193)
+++ trunk/launchd/src/SystemStarter.c	2007-03-30 03:11:46 UTC (rev 23194)
@@ -46,7 +46,7 @@
 static void     usage(void) __attribute__((noreturn));
 static int      system_starter(Action anAction, const char *aService);
 static void	displayErrorMessages(StartupContext aStartupContext);
-static pid_t	fwexec(const char *const *argv, bool _wait);
+static pid_t	fwexec(const char *cmd, ...) __attribute__((sentinel));
 
 int 
 main(int argc, char *argv[])
@@ -124,8 +124,6 @@
 
 	unlink(kFixerPath);
 
-	const char *ipw_cmd[] = { "/usr/sbin/ipconfig", "waitall", NULL };
-	const char *adm_cmd[] = { "/sbin/autodiskmount", "-va", NULL };
 	mach_timespec_t w = { 600, 0 };
 	kern_return_t kr;
 	struct stat sb;
@@ -142,15 +140,13 @@
 		syslog(LOG_NOTICE, "IOKitWaitQuiet: %d\n", kr);
 	}
 
-	fwexec(ipw_cmd, true);
-	fwexec(adm_cmd, true);
+	fwexec("/usr/sbin/ipconfig", "waitall", NULL);
+	fwexec("/sbin/autodiskmount", "-va", NULL);
 
 	system_starter(kActionStart, NULL);
 
 	if (stat("/etc/rc.local", &sb) != -1) {
-		const char *rc_local_cmd[] = { _PATH_BSHELL, "/etc/rc.local", NULL };
-
-		fwexec(rc_local_cmd, true);
+		fwexec(_PATH_BSHELL, "/etc/rc.local", NULL);
 	}
 
 	CFNotificationCenterPostNotificationWithOptions(
@@ -164,9 +160,7 @@
 	assert(kev.filter == EVFILT_SIGNAL && kev.ident == SIGTERM);
 
 	if (stat("/etc/rc.shutdown.local", &sb) != -1) {
-		const char *rc_shutdown_local_cmd[] = { _PATH_BSHELL, "/etc/rc.shutdown.local", NULL };
-
-		fwexec(rc_shutdown_local_cmd, true);
+		fwexec(_PATH_BSHELL, "/etc/rc.shutdown.local", NULL);
 	}
 
 	system_starter(kActionStop, NULL);
@@ -400,11 +394,19 @@
 }
 
 pid_t
-fwexec(const char *const *argv, bool _wait)
+fwexec(const char *cmd, ...)
 {
-	int wstatus;
+	const char *argv[100] = { cmd };
+	va_list ap;
+	int wstatus, i = 1;
 	pid_t p;
 
+	va_start(ap, cmd);
+	do {
+		argv[i] = va_arg(ap, char *);
+	} while (argv[i++]);
+	va_end(ap);
+
 	switch ((p = fork())) {
 	case -1:
 		return -1;
@@ -413,8 +415,6 @@
 		_exit(EXIT_FAILURE);
 		break;
 	default:
-		if (!_wait)
-			return p;
 		if (waitpid(p, &wstatus, 0) == -1) {
 			return -1;
 		} else if (WIFEXITED(wstatus)) {

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070329/ac8ed1b9/attachment.html


More information about the launchd-changes mailing list