[launchd-changes] [23079] trunk/launchd/src

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 16 09:45:28 PST 2007


Revision: 23079
          http://trac.macosforge.org/projects/launchd/changeset/23079
Author:   zarzycki at apple.com
Date:     2007-02-16 09:45:28 -0800 (Fri, 16 Feb 2007)

Log Message:
-----------
The last StartupItem installed by launchd is now dead. :-)

Modified Paths:
--------------
    trunk/launchd/src/Makefile.am
    trunk/launchd/src/Makefile.in
    trunk/launchd/src/StartupItems.c
    trunk/launchd/src/SystemStarter.c

Removed Paths:
-------------
    trunk/launchd/src/StartupItems/

Modified: trunk/launchd/src/Makefile.am
===================================================================
--- trunk/launchd/src/Makefile.am	2007-02-16 17:21:59 UTC (rev 23078)
+++ trunk/launchd/src/Makefile.am	2007-02-16 17:45:28 UTC (rev 23079)
@@ -68,17 +68,7 @@
 
 man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 service.8 launchproxy.8
 
-STARTUPITEMS = $(basename $(notdir $(wildcard $(srcdir)/StartupItems/*.plist)))
-
-$(addprefix $(DESTDIR)/System/Library/StartupItems/, $(STARTUPITEMS)):
-	mkdir -p $@
-	cp $(srcdir)/StartupItems/$(notdir $@) $@
-	chmod 755 $@/$(notdir $@)
-	cp $(srcdir)/StartupItems/$(notdir $@).plist $@/StartupParameters.plist
-
-install-startupitems: $(addprefix $(DESTDIR)/System/Library/StartupItems/, $(STARTUPITEMS))
-
-install-data-hook: install-startupitems
+install-data-hook:
 	mkdir -p $(DESTDIR)/usr/libexec
 	cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec
 	mkdir -p $(DESTDIR)/usr/include/servers

Modified: trunk/launchd/src/Makefile.in
===================================================================
--- trunk/launchd/src/Makefile.in	2007-02-16 17:21:59 UTC (rev 23078)
+++ trunk/launchd/src/Makefile.in	2007-02-16 17:45:28 UTC (rev 23079)
@@ -249,7 +249,6 @@
 @LIBS_ONLY_FALSE at man1_MANS = wait4path.1 launchctl.1
 @LIBS_ONLY_FALSE at man5_MANS = launchd.plist.5 launchd.conf.5
 @LIBS_ONLY_FALSE at man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 service.8 launchproxy.8
- at LIBS_ONLY_FALSE@STARTUPITEMS = $(basename $(notdir $(wildcard $(srcdir)/StartupItems/*.plist)))
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
@@ -1075,15 +1074,7 @@
 @LIBS_ONLY_FALSE at launchd_internal.h launchd_internalServer.c launchd_internalUser.c launchd_internalServer.h: $(srcdir)/launchd_internal.defs
 @LIBS_ONLY_FALSE@	mig $(MIGFLAGS) -sheader launchd_internalServer.h $(srcdir)/launchd_internal.defs
 
- at LIBS_ONLY_FALSE@$(addprefix $(DESTDIR)/System/Library/StartupItems/, $(STARTUPITEMS)):
- at LIBS_ONLY_FALSE@	mkdir -p $@
- at LIBS_ONLY_FALSE@	cp $(srcdir)/StartupItems/$(notdir $@) $@
- at LIBS_ONLY_FALSE@	chmod 755 $@/$(notdir $@)
- at LIBS_ONLY_FALSE@	cp $(srcdir)/StartupItems/$(notdir $@).plist $@/StartupParameters.plist
-
- at LIBS_ONLY_FALSE@install-startupitems: $(addprefix $(DESTDIR)/System/Library/StartupItems/, $(STARTUPITEMS))
-
- at LIBS_ONLY_FALSE@install-data-hook: install-startupitems
+ at LIBS_ONLY_FALSE@install-data-hook:
 @LIBS_ONLY_FALSE@	mkdir -p $(DESTDIR)/usr/libexec
 @LIBS_ONLY_FALSE@	cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec
 @LIBS_ONLY_FALSE@	mkdir -p $(DESTDIR)/usr/include/servers

Modified: trunk/launchd/src/StartupItems.c
===================================================================
--- trunk/launchd/src/StartupItems.c	2007-02-16 17:21:59 UTC (rev 23078)
+++ trunk/launchd/src/StartupItems.c	2007-02-16 17:45:28 UTC (rev 23079)
@@ -158,6 +158,7 @@
 		CFSTR("Core Services"),
 		CFSTR("Network"),
 		CFSTR("TIM"),
+		CFSTR("Disks"),
 		NULL
 	};
 	CFMutableArrayRef aList, aNewList;
@@ -959,7 +960,6 @@
 
 			case 0:	/* Child */
 				{
-					setpriority(PRIO_PROCESS, 0, 0);
 					if (setsid() == -1)
 						syslog(LOG_WARNING, "Unable to create session for item %s: %m", anExecutable);
 

Modified: trunk/launchd/src/SystemStarter.c
===================================================================
--- trunk/launchd/src/SystemStarter.c	2007-02-16 17:21:59 UTC (rev 23078)
+++ trunk/launchd/src/SystemStarter.c	2007-02-16 17:45:28 UTC (rev 23079)
@@ -44,6 +44,7 @@
 static int      system_starter(Action anAction, const char *aService);
 static void	displayErrorMessages(StartupContext aStartupContext);
 static void	doCFnote(void);
+static pid_t	fwexec(const char *const *argv, bool _wait);
 
 int 
 main(int argc, char *argv[])
@@ -112,11 +113,9 @@
 	if (argc == 2) {
 		aService = argv[1];
 	} else if (!gDebugFlag && anAction != kActionStop) {
-		pid_t ipwa;
-		int status;
+		const char *ipw_cmd[] = { "/usr/sbin/ipconfig", "waitall", NULL };
+		const char *adm_cmd[] = { "/sbin/autodiskmount", "-va", NULL };
 
-		setpriority(PRIO_PROCESS, 0, 20);
-
 		/* Too many old StartupItems had implicit dependancies on
 		 * "Network" via other StartupItems that are now no-ops.
 		 *
@@ -124,30 +123,8 @@
 		 * so we'll stall here to deal with this legacy dependancy
 		 * problem.
 		 */
-		switch ((ipwa = fork())) {
-		case -1:
-			syslog(LOG_WARNING, "fork(): %m");
-			break;
-		case 0:
-			execl("/usr/sbin/ipconfig", "ipconfig", "waitall", NULL);
-			syslog(LOG_WARNING, "execl(): %m");
-			exit(EXIT_FAILURE);
-		default:
-			if (waitpid(ipwa, &status, 0) == -1) {
-				syslog(LOG_WARNING, "waitpid(): %m");
-				break;
-			} else if (WIFEXITED(status)) {
-				if (WEXITSTATUS(status) == 0) {
-					break;
-				} else {
-					syslog(LOG_WARNING, "ipconfig waitall exit status: %d", WEXITSTATUS(status));
-				}
-			} else {
-				/* must have died due to signal */
-				syslog(LOG_WARNING, "ipconfig waitall: %s", strsignal(WTERMSIG(status)));
-			}
-			break;
-		}
+		fwexec(ipw_cmd, true);
+		fwexec(adm_cmd, true);
 	}
 
 	int ssec = system_starter(anAction, aService);
@@ -406,3 +383,38 @@
 			NULL, NULL,
 			kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
 }
+
+pid_t
+fwexec(const char *const *argv, bool _wait)
+{
+	int wstatus;
+	pid_t p;
+
+	switch ((p = fork())) {
+	case -1:
+		return -1;
+	case 0:
+		setsid();
+		execvp(argv[0], (char *const *)argv);
+		_exit(EXIT_FAILURE);
+		break;
+	default:
+		if (!_wait)
+			return p;
+		if (waitpid(p, &wstatus, 0) == -1) {
+			return -1;
+		} else if (WIFEXITED(wstatus)) {
+			if (WEXITSTATUS(wstatus) == 0) {
+				return 0;
+			} else {
+				syslog(LOG_WARNING, "%s exit status: %d", argv[0], WEXITSTATUS(wstatus));
+			}
+		} else {
+			/* must have died due to signal */
+			syslog(LOG_WARNING, "%s died: %s", argv[0], strsignal(WTERMSIG(wstatus)));
+		}
+		break;
+	}
+
+	return -1;
+}

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


More information about the launchd-changes mailing list