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

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 8 10:04:07 PST 2007


Revision: 23045
          http://trac.macosforge.org/projects/launchd/changeset/23045
Author:   zarzycki at apple.com
Date:     2007-02-08 10:04:06 -0800 (Thu, 08 Feb 2007)

Log Message:
-----------
Dead code deletion.

Modified Paths:
--------------
    trunk/launchd/src/launchd.8
    trunk/launchd/src/launchd.c
    trunk/launchd/src/launchd.h
    trunk/launchd/src/launchd_core_logic.c

Modified: trunk/launchd/src/launchd.8
===================================================================
--- trunk/launchd/src/launchd.8	2007-02-08 17:26:17 UTC (rev 23044)
+++ trunk/launchd/src/launchd.8	2007-02-08 18:04:06 UTC (rev 23045)
@@ -37,14 +37,10 @@
 is invoked by the kernel to run as the first process on the system and to further bootstrap the rest of the system.
 .Sh OPTIONS
 .Bl -tag -width -indent
-.It Fl d
-Daemonize. Useful when passing a command to launchd on the command line.
 .It Fl D
 Debug. Prints syslog messages to stderr and adjusts logging via
 .Xr syslog 3
 to LOG_DEBUG.
-.It Fl S Ar SessionType
-Instruct launchd to which session type it is.
 .El
 .Sh OPTIONS WHEN RUN AS PID 1
 .Bl -tag -width -indent

Modified: trunk/launchd/src/launchd.c
===================================================================
--- trunk/launchd/src/launchd.c	2007-02-08 17:26:17 UTC (rev 23044)
+++ trunk/launchd/src/launchd.c	2007-02-08 18:04:06 UTC (rev 23045)
@@ -83,12 +83,10 @@
 extern char **environ;
 
 static void signal_callback(void *, struct kevent *);
-static void ppidexit_callback(void);
 static void debugshutdown_callback(void);
 static void pfsystem_callback(void *, struct kevent *);
 
 static kq_callback kqsignal_callback = signal_callback;
-static kq_callback kqppidexit_callback = (kq_callback)ppidexit_callback;
 static kq_callback kqdebugshutdown_callback = (kq_callback)debugshutdown_callback;
 static kq_callback kqpfsystem_callback = pfsystem_callback;
 
@@ -123,17 +121,15 @@
 		SIGTTIN, SIGTTOU, SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF,
 		SIGWINCH, SIGINFO, SIGUSR1, SIGUSR2
 	};
-	bool sflag = false, dflag = false, Dflag = false;
+	bool sflag = false, Dflag = false;
 	char ldconf[PATH_MAX] = PID1LAUNCHD_CONF;
 	const char *h = getenv("HOME");
-	const char *session_type = NULL;
 	const char *optargs = NULL;
-	job_t fbj = NULL;
 	struct stat sb;
 	size_t i, checkin_fdcnt = 0;
 	int *checkin_fds = NULL;
 	mach_port_t checkin_mport = MACH_PORT_NULL;
-	int ch, ker, logopts;
+	int ch, logopts;
 
 	testfd_or_openfd(STDIN_FILENO, _PATH_DEVNULL, O_RDONLY);
 	testfd_or_openfd(STDOUT_FILENO, _PATH_DEVNULL, O_WRONLY);
@@ -200,14 +196,12 @@
 	if (getpid() == 1) {
 		optargs = "s";
 	} else {
-		optargs = "DS:dh";
+		optargs = "Dh";
 	}
 
 	while ((ch = getopt(argc, argv, optargs)) != -1) {
 		switch (ch) {
-		case 'S': session_type = optarg; break;	/* what type of session we're creating */
 		case 'D': Dflag = true;   break;	/* debug */
-		case 'd': dflag = true;   break;	/* daemonize */
 		case 's': sflag = true;   break;	/* single user */
 		case 'h': usage(stdout);  break;	/* help */
 		case '?': /* we should do something with the global optopt variable here */
@@ -222,10 +216,6 @@
 
 	/* main phase three: get the party started */
 
-	if (dflag) {
-		launchd_assumes(daemon(0, 0) == 0);
-	}
-
 	logopts = LOG_PID|LOG_CONS;
 	if (Dflag) {
 		logopts |= LOG_PERROR;
@@ -254,10 +244,6 @@
 	rlcj = job_new(root_jobmgr, READCONF_LABEL, NULL, launchctl_bootstrap_tool, ldconf);
 	launchd_assert(rlcj != NULL);
 
-	if (argv[0]) {
-		fbj = job_new(root_jobmgr, FIRSTBORN_LABEL, NULL, (const char *const *)argv, NULL);
-	}
-
 	if (NULL == getenv("PATH")) {
 		setenv("PATH", _PATH_STDPATH, 1);
 	}
@@ -270,27 +256,6 @@
 
 	monitor_networking_state();
 
-	if (session_type) {
-		pid_t pp = getppid();
-
-		/* As a per session launchd, we need to exit if our parent dies.
-		 *
-		 * Normally, in Unix, SIGHUP would cause us to exit, but we're a
-		 * daemon, and daemons use SIGHUP to signal the need to reread
-		 * configuration files. "Weee."
-		 */
-
-		if (pp == 1) {
-			exit(EXIT_SUCCESS);
-		}
-
-		ker = kevent_mod(pp, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, &kqppidexit_callback);
-
-		if (ker == -1) {
-			exit(launchd_assumes(errno == ESRCH) ? EXIT_SUCCESS : EXIT_FAILURE);
-		}
-	}
-
 	/*
 	 * We cannot stat() anything in the home directory right now.
 	 *
@@ -304,10 +269,6 @@
 		rlcj = job_dispatch(rlcj, true);
 	}
 
-	if (fbj) {
-		fbj = job_dispatch(fbj, true);
-	}
-
 	char *doom_why = "at instruction";
 	switch (setjmp(doom_doom_doom)) {
 		case 0:
@@ -431,17 +392,6 @@
 }
 
 void
-ppidexit_callback(void)
-{
-	syslog(LOG_INFO, "Parent process exited");
-
-	launchd_shutdown();
-
-	/* Let's just bail for now. We should really try to wait for jobs to exit first. */
-	exit(EXIT_SUCCESS);
-}
-
-void
 launchd_shutdown(void)
 {
 	if (shutdown_in_progress) {

Modified: trunk/launchd/src/launchd.h
===================================================================
--- trunk/launchd/src/launchd.h	2007-02-08 17:26:17 UTC (rev 23044)
+++ trunk/launchd/src/launchd.h	2007-02-08 18:04:06 UTC (rev 23045)
@@ -26,7 +26,6 @@
 #include "libbootstrap_public.h"
 #include "launchd_runtime.h"
 
-#define FIRSTBORN_LABEL "com.apple.launchd.firstborn"
 #define READCONF_LABEL "com.apple.launchd.readconfig"
 
 struct kevent;

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2007-02-08 17:26:17 UTC (rev 23044)
+++ trunk/launchd/src/launchd_core_logic.c	2007-02-08 18:04:06 UTC (rev 23045)
@@ -263,10 +263,9 @@
 	time_t start_time;
 	time_t min_run_time;
 	unsigned int start_interval;
-	unsigned int checkedin:1, firstborn:1, debug:1, inetcompat:1, inetcompat_wait:1,
+	unsigned int checkedin:1, anonymous:1, debug:1, inetcompat:1, inetcompat_wait:1,
 		     ondemand:1, session_create:1, low_pri_io:1, no_init_groups:1, priv_port_has_senders:1,
-		     importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1,
-		     anonymous:1;
+		     importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1;
 	mode_t mask;
 	unsigned int globargv:1, wait4debugger:1, unload_at_exit:1, stall_before_exec:1, only_once:1,
 		     currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1;
@@ -926,7 +925,6 @@
 	j->currently_ignored = true;
 	j->ondemand = true;
 	j->checkedin = true;
-	j->firstborn = (strcmp(label, FIRSTBORN_LABEL) == 0);
 
 	if (prog) {
 		j->prog = strdup(prog);
@@ -1760,13 +1758,7 @@
 	switch (kev->filter) {
 	case EVFILT_PROC:
 		job_reap(j);
-
-		if (j->firstborn) {
-			job_log(j, LOG_DEBUG, "first born died, begin shutdown");
-			launchd_shutdown();
-		} else {
-			job_dispatch(j, false);
-		}
+		job_dispatch(j, false);
 		break;
 	case EVFILT_TIMER:
 		if ((uintptr_t)j == kev->ident || (uintptr_t)&j->start_interval == kev->ident) {
@@ -1879,14 +1871,6 @@
 		job_assumes(j, close(execspair[0]) == 0);
 		/* wait for our parent to say they've attached a kevent to us */
 		read(_fd(execspair[1]), &c, sizeof(c));
-		if (j->firstborn) {
-			setpgid(getpid(), getpid());
-			if (isatty(STDIN_FILENO)) {
-				if (tcsetpgrp(STDIN_FILENO, getpid()) == -1) {
-					job_log_error(j, LOG_WARNING, "tcsetpgrp()");
-				}
-			}
-		}
 
 		if (sipc) {
 			job_assumes(j, close(spair[0]) == 0);

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


More information about the launchd-changes mailing list