[launchd-changes] [23229] trunk/launchd/src/launchd_core_logic.c

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 19 08:01:41 PDT 2007


Revision: 23229
          http://trac.macosforge.org/projects/launchd/changeset/23229
Author:   zarzycki at apple.com
Date:     2007-04-19 08:01:41 -0700 (Thu, 19 Apr 2007)

Log Message:
-----------
Prep for the arrival of NOTE_REAP.

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

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2007-04-18 17:30:47 UTC (rev 23228)
+++ trunk/launchd/src/launchd_core_logic.c	2007-04-19 15:01:41 UTC (rev 23229)
@@ -995,12 +995,18 @@
 	}
 
 	if (jobmgr_assumes(jm, (jr = job_new(jm, AUTO_PICK_LEGACY_LABEL, kp.kp_proc.p_comm, NULL)) != NULL)) {
+		u_int proc_fflags = NOTE_EXEC|NOTE_EXIT;
+
+#ifdef NOTE_REAP
+		proc_fflags |= NOTE_REAP;
+#endif
+
 		total_children++;
 		jr->anonymous = true;
 		jr->p = anonpid;
 		/* anonymous process reaping is messy */
 		LIST_INSERT_HEAD(&jm->active_jobs[ACTIVE_JOB_HASH(jr->p)], jr, pid_hash_sle);
-		job_assumes(jr, kevent_mod(jr->p, EVFILT_PROC, EV_ADD, NOTE_EXEC|NOTE_EXIT, 0, root_jobmgr) != -1);
+		job_assumes(jr, kevent_mod(jr->p, EVFILT_PROC, EV_ADD, proc_fflags, 0, root_jobmgr) != -1);
 		if (shutdown_state && jm->hopefully_first_cnt == 0) {
 			job_log(jr, LOG_APPLEONLY, "This process showed up to the party while all the guests were leaving. Odds are that it will have a miserable time. Blame PID %u: %s",
 				kp.kp_eproc.e_ppid, ppid_kp.kp_proc.p_comm);
@@ -1977,9 +1983,15 @@
 		if (j->anonymous) {
 			job_remove(j);
 		} else {
-			job_dispatch(j, false);
+			j = job_dispatch(j, false);
 		}
 	}
+
+#ifdef NOTE_REAP
+	if (j && (fflags & NOTE_REAP)) {
+		job_assumes(j, j->p == 0);
+	}
+#endif
 }
 
 void
@@ -2102,7 +2114,12 @@
 	pid_t c;
 	bool sipc = false;
 	time_t td;
+	u_int proc_fflags = /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT;
 
+#ifdef NOTE_REAP
+	proc_fflags |= NOTE_REAP;
+#endif
+
 	if (!job_assumes(j, j->mgr != NULL)) {
 		return;
 	}
@@ -2201,11 +2218,10 @@
 			job_assumes(j, runtime_close(spair[1]) == 0);
 			ipc_open(_fd(spair[0]), j);
 		}
-		if (kevent_mod(c, EVFILT_PROC, EV_ADD, /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT, 0, root_jobmgr ? root_jobmgr : j->mgr) == -1) {
-			job_log_error(j, LOG_ERR, "kevent()");
+		if (job_assumes(j, kevent_mod(c, EVFILT_PROC, EV_ADD, proc_fflags, 0, root_jobmgr ? root_jobmgr : j->mgr) != -1)) {
+			job_ignore(j);
+		} else {
 			job_reap(j);
-		} else {
-			job_ignore(j);
 		}
 
 		if (!j->stall_before_exec) {

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


More information about the launchd-changes mailing list