X-Git-Url: https://git.saurik.com/apple/launchd.git/blobdiff_plain/587e987eefe38fd31fb51b6d52f422eac67bdf8e..f70a210cfaa6d15038f6941e4e82cc003425decd:/launchd/src/launchd_core_logic.c diff --git a/launchd/src/launchd_core_logic.c b/launchd/src/launchd_core_logic.c index 58f8bd8..6daf059 100644 --- a/launchd/src/launchd_core_logic.c +++ b/launchd/src/launchd_core_logic.c @@ -16,7 +16,7 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ -static const char *const __rcs_file_version__ = "$Revision: 24003 $"; +static const char *const __rcs_file_version__ = "$Revision: 24498 $"; #include "config.h" #include "launchd_core_logic.h" @@ -1439,7 +1439,7 @@ job_new_anonymous(jobmgr_t jm, pid_t anonpid) } if (jobmgr_assumes(jm, (jr = job_new(jm, AUTO_PICK_ANONYMOUS_LABEL, kp.kp_proc.p_comm, NULL)) != NULL)) { - u_int proc_fflags = NOTE_EXEC|NOTE_FORK|NOTE_EXIT|NOTE_REAP; + u_int proc_fflags = NOTE_EXEC|NOTE_FORK|NOTE_EXIT; total_anon_children++; jr->anonymous = true; @@ -2785,7 +2785,8 @@ job_reap(job_t j) LIST_REMOVE(spi, sle); free(spi); } - + + j->last_exit_status = status; struct waiting_for_exit *w4e = NULL; while( (w4e = LIST_FIRST(&j->exit_watchers)) ) { waiting4exit_delete(j, w4e); @@ -2810,7 +2811,6 @@ job_reap(job_t j) } else if (!j->anonymous && !j->hopefully_exits_last) { j->mgr->normal_active_cnt--; } - j->last_exit_status = status; j->sent_signal_time = 0; j->sent_sigkill = false; j->clean_kill = false; @@ -3338,10 +3338,6 @@ job_callback_proc(job_t j, struct kevent *kev) j = NULL; } } - - if (j && (fflags & NOTE_REAP)) { - job_assumes(j, j->p == 0); - } } void @@ -3588,7 +3584,7 @@ job_start(job_t j) char nbuf[64]; pid_t c; bool sipc = false; - u_int proc_fflags = NOTE_EXIT|NOTE_FORK|NOTE_EXEC|NOTE_REAP; + u_int proc_fflags = NOTE_EXIT|NOTE_FORK|NOTE_EXEC; if (!job_assumes(j, j->mgr != NULL)) { return; @@ -8296,6 +8292,12 @@ job_mig_init_session(job_t j, name_t session_type, mach_port_t audit_session) kern_return_t job_mig_switch_to_session(job_t j, mach_port_t requestor_port, name_t session_name, mach_port_t audit_session, mach_port_t *new_bsport) { + struct ldcred *ldc = runtime_get_caller_creds(); + if (!jobmgr_assumes(root_jobmgr, j != NULL)) { + jobmgr_log(root_jobmgr, LOG_ERR, "%s() called with NULL job: PID %d", __func__, ldc->pid); + return BOOTSTRAP_NO_MEMORY; + } + job_log(j, LOG_DEBUG, "Job wants to move to %s session.", session_name); if( !job_assumes(j, pid1_magic == false) ) {