From source_changes at macosforge.org Thu Mar 1 10:21:52 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:42 2007 Subject: [launchd-changes] [23119] trunk/launchd/src/launchd_runtime.c Message-ID: <20070301182152.AC1134C0028@cvs.opensource.apple.com> Revision: 23119 http://trac.macosforge.org/projects/launchd/changeset/23119 Author: zarzycki@apple.com Date: 2007-03-01 10:21:52 -0800 (Thu, 01 Mar 2007) Log Message: ----------- More logging. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-02-28 23:39:18 UTC (rev 23118) +++ trunk/launchd/src/launchd_runtime.c 2007-03-01 18:21:52 UTC (rev 23119) @@ -658,6 +658,7 @@ struct kevent kev; if (launchd_assumes(kevent(asynckq, NULL, 0, &kev, 1, &timeout) == 1)) { + log_kevent_struct(LOG_DEBUG, &kev); (*((kq_callback *)kev.udata))(kev.udata, &kev); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070301/015db17a/attachment.html From source_changes at macosforge.org Thu Mar 1 11:15:03 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23120] trunk/launchd/src/rc.8 Message-ID: <20070301191503.0F77F4C00E2@cvs.opensource.apple.com> Revision: 23120 http://trac.macosforge.org/projects/launchd/changeset/23120 Author: zarzycki@apple.com Date: 2007-03-01 11:15:02 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Fix a simple nroff error. Modified Paths: -------------- trunk/launchd/src/rc.8 Modified: trunk/launchd/src/rc.8 =================================================================== --- trunk/launchd/src/rc.8 2007-03-01 18:21:52 UTC (rev 23119) +++ trunk/launchd/src/rc.8 2007-03-01 19:15:02 UTC (rev 23120) @@ -1,6 +1,6 @@ .Dd May 31, 2006 .Dt RC 8 -.Os Darwin 9 +.Os Darwin .Sh NAME .Nm rc .Nd command script for boot -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070301/e98dd5cd/attachment.html From source_changes at macosforge.org Thu Mar 1 11:19:11 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23121] trunk/launchd/src/launchd_runtime.c Message-ID: <20070301191911.AE8EC4C00F2@cvs.opensource.apple.com> Revision: 23121 http://trac.macosforge.org/projects/launchd/changeset/23121 Author: zarzycki@apple.com Date: 2007-03-01 11:19:11 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Move some of the more variable length output of kevent debug logs to the end of the log message. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-01 19:15:02 UTC (rev 23120) +++ trunk/launchd/src/launchd_runtime.c 2007-03-01 19:19:11 UTC (rev 23121) @@ -393,8 +393,8 @@ break; } - runtime_syslog(level, "KEVENT: ident = %s filter = %s flags = %s fflags = %s data = 0x%lx udata = %p", - ident_buf, filter_str, flags_buf, fflags_buf, kev->data, kev->udata); + runtime_syslog(level, "KEVENT: udata = %p data = 0x%lx ident = %s filter = %s flags = %s fflags = %s", + kev->udata, kev->data, ident_buf, filter_str, flags_buf, fflags_buf); } kern_return_t -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070301/6c4c3b05/attachment.html From source_changes at macosforge.org Thu Mar 1 20:04:38 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23122] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070302040438.412104C0BE0@cvs.opensource.apple.com> Revision: 23122 http://trac.macosforge.org/projects/launchd/changeset/23122 Author: zarzycki@apple.com Date: 2007-03-01 20:04:37 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Work around 5020256 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-03-01 19:19:11 UTC (rev 23121) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-02 04:04:37 UTC (rev 23122) @@ -303,7 +303,7 @@ static void job_force_sampletool(job_t j); static void job_reparent_hack(job_t j, const char *where); static void job_callback(void *obj, struct kevent *kev); -static void job_callback_proc(job_t j, int fflags); +static void job_callback_proc(job_t j, int flags, int fflags); static void job_callback_timer(job_t j, void *ident); static void job_callback_read(job_t j, int ident); static launch_data_t job_export2(job_t j, bool subjobs); @@ -1661,7 +1661,16 @@ } if (!job_assumes(j, wait4(j->p, &status, 0, &ru) != -1)) { - return; + /* + * wait4() then kill() is still racy. + * Then again, we never should have got here in the first place... + */ + if (kill(j->p, 0) == 0) { + job_log(j, LOG_DEBUG, "Working around 5020256"); + } + + status = 0; + memset(&ru, 0, sizeof(ru)); } if (j->exit_timeout) { @@ -1817,7 +1826,7 @@ } void -job_callback_proc(job_t j, int fflags) +job_callback_proc(job_t j, int flags, int fflags) { if (fflags & NOTE_EXEC) { job_log(j, LOG_DEBUG, "Called execve()"); @@ -1828,6 +1837,8 @@ } if (fflags & NOTE_EXIT) { + job_assumes(j, (flags & EV_ONESHOT)); + job_assumes(j, (flags & EV_EOF)); job_reap(j); job_dispatch(j, false); @@ -1904,7 +1915,7 @@ switch (kev->filter) { case EVFILT_PROC: - return job_callback_proc(j, kev->fflags); + return job_callback_proc(j, kev->flags, kev->fflags); case EVFILT_TIMER: return job_callback_timer(j, (void *)kev->ident); case EVFILT_VNODE: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070301/0351c7ab/attachment.html From source_changes at macosforge.org Fri Mar 2 15:46:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23123] tags/launchd-200/ Message-ID: <20070302234629.480494C5C28@cvs.opensource.apple.com> Revision: 23123 http://trac.macosforge.org/projects/launchd/changeset/23123 Author: zarzycki@apple.com Date: 2007-03-02 15:46:29 -0800 (Fri, 02 Mar 2007) Log Message: ----------- "Tagging launchd-200 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-200/ Copied: tags/launchd-200 (from rev 23122, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070302/7b0f88ff/attachment.html From source_changes at macosforge.org Sat Mar 3 15:09:50 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23124] trunk/launchd/src Message-ID: <20070303230950.109604C7F7C@cvs.opensource.apple.com> Revision: 23124 http://trac.macosforge.org/projects/launchd/changeset/23124 Author: zarzycki@apple.com Date: 2007-03-03 15:09:49 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Transform jobmgr_fork() to runtime_fork(). Someday, I'll create runtime_spawn() that wraps and extends posix_spawn(). Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-02 23:46:29 UTC (rev 23123) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-03 23:09:49 UTC (rev 23124) @@ -221,7 +221,6 @@ static job_t job_mig_intran2(jobmgr_t jm, mach_port_t p); static void job_export_all2(jobmgr_t jm, launch_data_t where); static void jobmgr_callback(void *obj, struct kevent *kev); -static pid_t jobmgr_fork(jobmgr_t jm); static void jobmgr_setup_env_from_other_jobs(jobmgr_t jm); static struct machservice *jobmgr_lookup_service(jobmgr_t jm, const char *name, bool check_parent, pid_t target_pid); static void jobmgr_logv(jobmgr_t jm, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0))); @@ -1986,7 +1985,7 @@ time(&j->start_time); - switch (c = jobmgr_fork(j->mgr)) { + switch (c = runtime_fork(j->mgr->jm_port)) { case -1: job_log_error(j, LOG_ERR, "fork() failed, will try again in one second"); job_assumes(j, close(execspair[0]) == 0); @@ -3088,29 +3087,6 @@ return false; } -pid_t -jobmgr_fork(jobmgr_t jm) -{ - mach_port_t p = jm->jm_port; - pid_t r = -1; - int saved_errno; - - jobmgr_assumes(jm, launchd_mport_make_send(p) == KERN_SUCCESS); - jobmgr_assumes(jm, launchd_set_bport(p) == KERN_SUCCESS); - jobmgr_assumes(jm, launchd_mport_deallocate(p) == KERN_SUCCESS); - - r = fork(); - - saved_errno = errno; - - if (r != 0) { - jobmgr_assumes(jm, launchd_set_bport(MACH_PORT_NULL) == KERN_SUCCESS); - } - - errno = saved_errno; - return r; -} - void machservice_watch(job_t j, struct machservice *ms) { Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-02 23:46:29 UTC (rev 23123) +++ trunk/launchd/src/launchd_runtime.c 2007-03-03 23:09:49 UTC (rev 23124) @@ -553,6 +553,30 @@ return errno; } +pid_t +runtime_fork(mach_port_t bsport) +{ + pid_t r = -1; + int saved_errno; + + launchd_assumes(launchd_mport_make_send(bsport) == KERN_SUCCESS); + launchd_assumes(launchd_set_bport(bsport) == KERN_SUCCESS); + launchd_assumes(launchd_mport_deallocate(bsport) == KERN_SUCCESS); + + r = fork(); + + saved_errno = errno; + + if (r != 0) { + launchd_assumes(launchd_set_bport(MACH_PORT_NULL) == KERN_SUCCESS); + } + + errno = saved_errno; + + return r; +} + + void runtime_set_timeout(timeout_callback to_cb, mach_msg_timeout_t to) { Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-03-02 23:46:29 UTC (rev 23123) +++ trunk/launchd/src/launchd_runtime.h 2007-03-03 23:09:49 UTC (rev 23124) @@ -71,6 +71,8 @@ int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata); +pid_t runtime_fork(mach_port_t bsport); + void runtime_openlog(const char *ident, int logopt, int facility); void runtime_closelog(void); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070303/5630b0c2/attachment.html From source_changes at macosforge.org Sat Mar 3 15:42:02 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23125] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070303234202.BE8064C7F9B@cvs.opensource.apple.com> Revision: 23125 http://trac.macosforge.org/projects/launchd/changeset/23125 Author: zarzycki@apple.com Date: 2007-03-03 15:42:02 -0800 (Sat, 03 Mar 2007) Log Message: ----------- launchd should have a per-user bootstrap context ("background session") 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-03-03 23:09:49 UTC (rev 23124) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-03 23:42:02 UTC (rev 23125) @@ -272,7 +272,7 @@ 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, removal_pending:1, - wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1; + wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_per_user_bootstrap:1; char label[0]; }; @@ -1649,6 +1649,17 @@ job_log(j, LOG_DEBUG, "Reaping"); + if (j->weird_per_user_bootstrap) { + mach_msg_size_t mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); + + if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) { + mxmsgsz = job_mig_protocol_vproc_subsystem.maxsize; + } + + job_assumes(j, runtime_add_mport(j->mgr->jm_port, protocol_vproc_server, mxmsgsz) == KERN_SUCCESS); + j->weird_per_user_bootstrap = false; + } + if (j->log_redirect_fd && (!j->wait4pipe_eof || j->mgr->shutting_down)) { job_assumes(j, close(j->log_redirect_fd) != -1); j->log_redirect_fd = 0; @@ -1985,7 +1996,7 @@ time(&j->start_time); - switch (c = runtime_fork(j->mgr->jm_port)) { + switch (c = runtime_fork(j->weird_per_user_bootstrap ? j->j_port : j->mgr->jm_port)) { case -1: job_log_error(j, LOG_ERR, "fork() failed, will try again in one second"); job_assumes(j, close(execspair[0]) == 0); @@ -3465,10 +3476,6 @@ mxmsgsz = job_mig_protocol_vproc_subsystem.maxsize; } - if (!jobmgr_assumes(jmr, runtime_add_mport(jmr->jm_port, protocol_vproc_server, mxmsgsz) == KERN_SUCCESS)) { - goto out_bad; - } - jobmgr_assumes(jmr, (jmr->anonj = jobmgr_get_anonymous(jmr)) != NULL); bootstrapper = job_new(jmr, "com.apple.launchctld", NULL, bootstrap_tool); @@ -3477,6 +3484,16 @@ jobmgr_assumes(jmr, kevent_mod(SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, jmr) != -1); } + if (!jm && getuid() != 0) { + /* per-user bootstrap context is messy */ + bootstrapper->weird_per_user_bootstrap = true; + jobmgr_assumes(jmr, job_setup_machport(bootstrapper)); + } else { + if (!jobmgr_assumes(jmr, runtime_add_mport(jmr->jm_port, protocol_vproc_server, mxmsgsz) == KERN_SUCCESS)) { + goto out_bad; + } + } + jobmgr_log(jmr, LOG_DEBUG, "Created job manager%s%s", jm ? " with parent: " : ".", jm ? jm->name : ""); if (!jm && jobmgr_assumes(jmr, bootstrapper != NULL)) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070303/83c0dc73/attachment.html From source_changes at macosforge.org Sat Mar 3 16:13:12 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23126] trunk/launchd/src/liblaunch.c Message-ID: <20070304001312.D32784C7FBE@cvs.opensource.apple.com> Revision: 23126 http://trac.macosforge.org/projects/launchd/changeset/23126 Author: zarzycki@apple.com Date: 2007-03-03 16:13:12 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Stuck at black screen with text about nfs_connect after logout (after disconnecting from VPN) Modified Paths: -------------- trunk/launchd/src/liblaunch.c Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2007-03-03 23:42:02 UTC (rev 23125) +++ trunk/launchd/src/liblaunch.c 2007-03-04 00:13:12 UTC (rev 23126) @@ -1189,7 +1189,8 @@ void load_launchd_jobs_at_loginwindow_prompt(int flags, ...) { - char *largv[] = { "/bin/launchctl", "load", "-S", "LoginWindow", "-D", "all", "/etc/mach_init_per_login_session.d", NULL }; + char *largv[] = { "/bin/launchctl", "load", "-S", "LoginWindow", + "-D", "system", "-D", "local", "/etc/mach_init_per_login_session.d", NULL }; int wstatus; pid_t p; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070303/38be1ee9/attachment.html From source_changes at macosforge.org Sat Mar 3 17:28:51 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23127] trunk/launchd/src Message-ID: <20070304012851.86DEF4C80AD@cvs.opensource.apple.com> Revision: 23127 http://trac.macosforge.org/projects/launchd/changeset/23127 Author: zarzycki@apple.com Date: 2007-03-03 17:28:51 -0800 (Sat, 03 Mar 2007) Log Message: ----------- private API (on behalf of seatbelt) request: do bootstrap lookup of X in user Y's context Modified Paths: -------------- trunk/launchd/src/libbootstrap.c trunk/launchd/src/libbootstrap_private.h Modified: trunk/launchd/src/libbootstrap.c =================================================================== --- trunk/launchd/src/libbootstrap.c 2007-03-04 00:13:12 UTC (rev 23126) +++ trunk/launchd/src/libbootstrap.c 2007-03-04 01:28:51 UTC (rev 23127) @@ -27,6 +27,10 @@ #include #include +#include +#include +#include +#include #include "protocol_vproc.h" @@ -100,6 +104,28 @@ } kern_return_t +bootstrap_look_up_per_user(mach_port_t bp, name_t service_name, uid_t target_user, mach_port_t *sp) +{ + struct stat sb; + kern_return_t kr; + mach_port_t puc; + + if (!pthread_main_np() && (stat("/AppleInternal", &sb) != -1)) { + _vproc_log(LOG_WARNING, "Please review the comments in 4890134."); + } + + if ((kr = vproc_mig_lookup_per_user_context(bp, target_user, &puc)) != 0) { + return kr; + } + + kr = vproc_mig_look_up2(puc, service_name, sp, 0, 0); + mach_port_deallocate(mach_task_self(), puc); + + return kr; +} + + +kern_return_t bootstrap_look_up(mach_port_t bp, name_t service_name, mach_port_t *sp) { return bootstrap_look_up2(bp, service_name, sp, 0, 0); Modified: trunk/launchd/src/libbootstrap_private.h =================================================================== --- trunk/launchd/src/libbootstrap_private.h 2007-03-04 00:13:12 UTC (rev 23126) +++ trunk/launchd/src/libbootstrap_private.h 2007-03-04 01:28:51 UTC (rev 23127) @@ -33,6 +33,8 @@ kern_return_t bootstrap_look_up2(mach_port_t bp, name_t service_name, mach_port_t *sp, pid_t target_pid, uint64_t flags); +kern_return_t bootstrap_look_up_per_user(mach_port_t bp, name_t service_name, uid_t target_user, mach_port_t *sp); + #pragma GCC visibility pop __END_DECLS -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070303/95d3d5af/attachment.html From source_changes at macosforge.org Sat Mar 3 19:51:12 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23128] trunk/launchd/src/libbootstrap.c Message-ID: <20070304035112.152024C812F@cvs.opensource.apple.com> Revision: 23128 http://trac.macosforge.org/projects/launchd/changeset/23128 Author: zarzycki@apple.com Date: 2007-03-03 19:51:11 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Fix a logic typo. Modified Paths: -------------- trunk/launchd/src/libbootstrap.c Modified: trunk/launchd/src/libbootstrap.c =================================================================== --- trunk/launchd/src/libbootstrap.c 2007-03-04 01:28:51 UTC (rev 23127) +++ trunk/launchd/src/libbootstrap.c 2007-03-04 03:51:11 UTC (rev 23128) @@ -110,7 +110,7 @@ kern_return_t kr; mach_port_t puc; - if (!pthread_main_np() && (stat("/AppleInternal", &sb) != -1)) { + if (pthread_main_np() && (stat("/AppleInternal", &sb) != -1)) { _vproc_log(LOG_WARNING, "Please review the comments in 4890134."); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070303/557c939d/attachment.html From source_changes at macosforge.org Sun Mar 4 09:34:05 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23129] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070304173405.86FE84C842F@cvs.opensource.apple.com> Revision: 23129 http://trac.macosforge.org/projects/launchd/changeset/23129 Author: zarzycki@apple.com Date: 2007-03-04 09:34:05 -0800 (Sun, 04 Mar 2007) Log Message: ----------- Bug: launchd_core_logic.c:4524 (23087):3: jmi != NULL 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-03-04 03:51:11 UTC (rev 23128) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-04 17:34:05 UTC (rev 23129) @@ -4568,6 +4568,10 @@ return; } + if (strcasecmp(j->mgr->name, where) == 0) { + return; + } + SLIST_FOREACH(jmi, &root_jobmgr->submgrs, sle) { if (strcasecmp(jmi->name, where) == 0) { break; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070304/ac5d1aab/attachment.html From source_changes at macosforge.org Sun Mar 4 15:38:22 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23130] trunk/launchd/src Message-ID: <20070304233822.29CE94C88D2@cvs.opensource.apple.com> Revision: 23130 http://trac.macosforge.org/projects/launchd/changeset/23130 Author: zarzycki@apple.com Date: 2007-03-04 15:38:21 -0800 (Sun, 04 Mar 2007) Log Message: ----------- launchd should be able to bootstrap itself Modified Paths: -------------- trunk/launchd/src/launchctl.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/liblaunch.c trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h trunk/launchd/src/protocol_job.defs Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-03-04 17:34:05 UTC (rev 23129) +++ trunk/launchd/src/launchctl.c 2007-03-04 23:38:21 UTC (rev 23130) @@ -250,8 +250,9 @@ } } - if (i > 0) + if (i > 0) { demux_cmd(i, argv2); + } free(l); } @@ -1243,7 +1244,7 @@ } static void -very_pid2_specific_bootstrap(bool sflag) +system_specific_bootstrap(bool sflag) { int hnmib[] = { CTL_KERN, KERN_HOSTNAME }; struct group *tfp_gr; @@ -1340,7 +1341,7 @@ _vproc_set_global_on_demand(true); - char *load_launchd_items[] = { "load", "-D", "all", "/etc/mach_init.d", NULL, NULL }; + char *load_launchd_items[] = { "load", "-D", "all", "/etc/mach_init.d", NULL }; if (is_safeboot()) { load_launchd_items[2] = "system"; @@ -1387,18 +1388,61 @@ } int -bootstrap_cmd(int argc, char *const argv[] __attribute__((unused))) +bootstrap_cmd(int argc, char *const argv[]) { - if (getuid() == 0) { - very_pid2_specific_bootstrap(argc == 2); + char *session_type = NULL; + bool sflag = false; + int ch; + + while ((ch = getopt(argc, argv, "sS:")) != -1) { + switch (ch) { + case 's': + sflag = true; + break; + case 'S': + session_type = optarg; + break; + case '?': + default: + break; + } + } + + optind = 1; + optreset = 1; + + if (!session_type) { + fprintf(stderr, "usage: %s bootstrap [-s] -S \n", getprogname()); + return 1; + } + + if (strcasecmp(session_type, "System") == 0) { + system_specific_bootstrap(sflag); } else { - char *load_launchd_items[] = { "load", "-D", "all", "-S", "Background", NULL }; + char *load_launchd_items[] = { "load", "-S", session_type, "-D", "all", NULL, NULL, NULL, NULL }; + int the_argc = 5; if (is_safeboot()) { - load_launchd_items[2] = "system"; + load_launchd_items[4] = "system"; } - assumes(load_and_unload_cmd(5, load_launchd_items) == 0); + if (strcasecmp(session_type, "Background") == 0 || strcasecmp(session_type, "LoginWindow") == 0) { + load_launchd_items[4] = "system"; + if (!is_safeboot()) { + load_launchd_items[5] = "-D"; + load_launchd_items[6] = "local"; + the_argc += 2; + } + if (strcasecmp(session_type, "LoginWindow") == 0) { + load_launchd_items[the_argc] = "/etc/mach_init_per_login_session.d"; + the_argc += 1; + } + } else if (strcasecmp(session_type, "Aqua") == 0) { + load_launchd_items[5] = "/etc/mach_init_per_user.d"; + the_argc += 1; + } + + assumes(load_and_unload_cmd(the_argc, load_launchd_items) == 0); } return 0; @@ -1416,8 +1460,9 @@ memset(&lus, 0, sizeof(lus)); - if (!strcmp(argv[0], "load")) + if (strcmp(argv[0], "load") == 0) { lus.load = true; + } while ((ch = getopt(argc, argv, "wFS:D:")) != -1) { switch (ch) { @@ -1431,20 +1476,20 @@ lus.session_type = optarg; break; case 'D': - if (strcasecmp(optarg, "all") == 0) { - es |= NSAllDomainsMask; - } else if (strcasecmp(optarg, "user") == 0) { - es |= NSUserDomainMask; - } else if (strcasecmp(optarg, "local") == 0) { - es |= NSLocalDomainMask; - } else if (strcasecmp(optarg, "network") == 0) { - es |= NSNetworkDomainMask; - } else if (strcasecmp(optarg, "system") == 0) { - es |= NSSystemDomainMask; - } else { + if (strcasecmp(optarg, "all") == 0) { + es |= NSAllDomainsMask; + } else if (strcasecmp(optarg, "user") == 0) { + es |= NSUserDomainMask; + } else if (strcasecmp(optarg, "local") == 0) { + es |= NSLocalDomainMask; + } else if (strcasecmp(optarg, "network") == 0) { + es |= NSNetworkDomainMask; + } else if (strcasecmp(optarg, "system") == 0) { + es |= NSSystemDomainMask; + } else { badopts = true; - } - break; + } + break; case '?': default: badopts = true; @@ -1454,11 +1499,13 @@ argc -= optind; argv += optind; - if (lus.session_type == NULL) + if (lus.session_type == NULL) { es &= ~NSUserDomainMask; + } - if (argc == 0 && es == 0) + if (argc == 0 && es == 0) { badopts = true; + } if (badopts) { fprintf(stderr, "usage: %s load [-wF] [-D ] paths...\n", getprogname()); @@ -1497,8 +1544,9 @@ } } - for (i = 0; i < (size_t)argc; i++) + for (i = 0; i < (size_t)argc; i++) { readpath(argv[i], &lus); + } if (launch_data_array_get_count(lus.pass0) == 0 && launch_data_array_get_count(lus.pass1) == 0 && Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-04 17:34:05 UTC (rev 23129) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-04 23:38:21 UTC (rev 23130) @@ -211,7 +211,7 @@ #define jobmgr_assumes(jm, e) \ (__builtin_expect(!(e), 0) ? jobmgr_log_bug(jm, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) -static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag); +static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name); static jobmgr_t jobmgr_parent(jobmgr_t jm); static jobmgr_t jobmgr_do_garbage_collection(jobmgr_t jm); static bool jobmgr_is_idle(jobmgr_t jm); @@ -272,7 +272,7 @@ 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, removal_pending:1, - wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_per_user_bootstrap:1; + wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1; char label[0]; }; @@ -1649,7 +1649,7 @@ job_log(j, LOG_DEBUG, "Reaping"); - if (j->weird_per_user_bootstrap) { + if (j->weird_bootstrap) { mach_msg_size_t mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) { @@ -1657,7 +1657,7 @@ } job_assumes(j, runtime_add_mport(j->mgr->jm_port, protocol_vproc_server, mxmsgsz) == KERN_SUCCESS); - j->weird_per_user_bootstrap = false; + j->weird_bootstrap = false; } if (j->log_redirect_fd && (!j->wait4pipe_eof || j->mgr->shutting_down)) { @@ -1996,7 +1996,7 @@ time(&j->start_time); - switch (c = runtime_fork(j->weird_per_user_bootstrap ? j->j_port : j->mgr->jm_port)) { + switch (c = runtime_fork(j->weird_bootstrap ? j->j_port : j->mgr->jm_port)) { case -1: job_log_error(j, LOG_ERR, "fork() failed, will try again in one second"); job_assumes(j, close(execspair[0]) == 0); @@ -3397,15 +3397,15 @@ } jobmgr_t -jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag) +jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name) { - const char *bootstrap_tool[] = { "/bin/launchctl", "bootstrap", NULL, NULL }; + const char *bootstrap_tool[] = { "/bin/launchctl", "bootstrap", "-S", name, NULL, NULL }; mach_msg_size_t mxmsgsz; job_t bootstrapper = NULL; jobmgr_t jmr; if (sflag) { - bootstrap_tool[2] = "-s"; + bootstrap_tool[4] = "-s"; } launchd_assert(offsetof(struct jobmgr_s, kqjobmgr_callback) == 0); @@ -3415,7 +3415,7 @@ return NULL; } - jmr = calloc(1, sizeof(struct jobmgr_s) + 30); + jmr = calloc(1, sizeof(struct jobmgr_s) + (name ? (strlen(name) + 1) : 128)); if (jmr == NULL) { return NULL; @@ -3423,7 +3423,7 @@ TAILQ_INIT(&jmr->jobs); jmr->kqjobmgr_callback = jobmgr_callback; - strcpy(jmr->name, "In-utero"); + strcpy(jmr->name, name ? name : "Under construction"); jmr->req_port = requestorport; @@ -3468,7 +3468,9 @@ goto out_bad; } - sprintf(jmr->name, "%u", MACH_PORT_INDEX(jmr->jm_port)); + if (!name) { + sprintf(jmr->name, "%u", MACH_PORT_INDEX(jmr->jm_port)); + } /* Sigh... at the moment, MIG has maxsize == sizeof(reply union) */ mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); @@ -3478,17 +3480,20 @@ jobmgr_assumes(jmr, (jmr->anonj = jobmgr_get_anonymous(jmr)) != NULL); - bootstrapper = job_new(jmr, "com.apple.launchctld", NULL, bootstrap_tool); - if (!jm) { jobmgr_assumes(jmr, kevent_mod(SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, jmr) != -1); } - if (!jm && getuid() != 0) { - /* per-user bootstrap context is messy */ - bootstrapper->weird_per_user_bootstrap = true; - jobmgr_assumes(jmr, job_setup_machport(bootstrapper)); - } else { + if (name) { + /* no name implies: bootstrap_subset() where creating a "bootstrapper" makes no sense */ + bootstrapper = job_new(jmr, "com.apple.launchctld", NULL, bootstrap_tool); + if (jm || getuid()) { + bootstrapper->weird_bootstrap = true; + jobmgr_assumes(jmr, job_setup_machport(bootstrapper)); + } + } + + if (!bootstrapper || !bootstrapper->weird_bootstrap) { if (!jobmgr_assumes(jmr, runtime_add_mport(jmr->jm_port, protocol_vproc_server, mxmsgsz) == KERN_SUCCESS)) { goto out_bad; } @@ -3496,7 +3501,7 @@ jobmgr_log(jmr, LOG_DEBUG, "Created job manager%s%s", jm ? " with parent: " : ".", jm ? jm->name : ""); - if (!jm && jobmgr_assumes(jmr, bootstrapper != NULL)) { + if (bootstrapper) { jobmgr_assumes(jmr, job_dispatch(bootstrapper, true) != NULL); } @@ -4586,7 +4591,7 @@ } kern_return_t -job_mig_move_subset_to_user(job_t j, mach_port_t target_subset) +job_mig_move_subset(job_t j, mach_port_t target_subset, name_t session_type) { mach_msg_type_number_t l2l_i, l2l_name_cnt = 0, l2l_port_cnt = 0; name_array_t l2l_names = NULL; @@ -4596,9 +4601,17 @@ jobmgr_t jmr; if (getuid() == 0) { + const char *bootstrap_tool[] = { "/bin/launchctl", "bootstrap", "-S", session_type, NULL }; + job_t bootstrapper; + j = job_mig_intran2(root_jobmgr, target_subset); + strcpy(j->mgr->name, session_type); job_assumes(j, launchd_mport_deallocate(target_subset) == KERN_SUCCESS); - strcpy(j->mgr->name, "Aqua"); + + bootstrapper = job_new(j->mgr, "com.apple.launchctld", NULL, bootstrap_tool); + if (job_assumes(j, bootstrapper != NULL)) { + job_dispatch(bootstrapper, true); + } return 0; } @@ -4613,13 +4626,11 @@ launchd_assert(l2l_name_cnt == l2l_port_cnt); - if ((jmr = jobmgr_new(j->mgr, reqport, rcvright, false)) == NULL) { + if ((jmr = jobmgr_new(j->mgr, reqport, rcvright, false, session_type)) == NULL) { kr = BOOTSTRAP_NO_MEMORY; goto out; } - strcpy(jmr->name, "Aqua"); - for (l2l_i = 0; l2l_i < l2l_name_cnt; l2l_i++) { struct machservice *ms; @@ -4742,7 +4753,7 @@ return BOOTSTRAP_NO_MEMORY; } - if ((jmr = jobmgr_new(j->mgr, requestorport, MACH_PORT_NULL, false)) == NULL) { + if ((jmr = jobmgr_new(j->mgr, requestorport, MACH_PORT_NULL, false, NULL)) == NULL) { if (requestorport == MACH_PORT_NULL) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -4917,5 +4928,5 @@ void jobmgr_init(bool sflag) { - launchd_assert((root_jobmgr = jobmgr_new(NULL, MACH_PORT_NULL, MACH_PORT_NULL, sflag)) != NULL); + launchd_assert((root_jobmgr = jobmgr_new(NULL, MACH_PORT_NULL, MACH_PORT_NULL, sflag, getpid() == 1 ? "System" : "Background")) != NULL); } Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2007-03-04 17:34:05 UTC (rev 23129) +++ trunk/launchd/src/liblaunch.c 2007-03-04 23:38:21 UTC (rev 23130) @@ -1160,101 +1160,28 @@ return r; } -static pid_t -fexecv_as_user(const char *login, uid_t u, gid_t g, char *const argv[]) -{ - int i, dtsz; - pid_t p; - - if ((p = fork()) != 0) - return p; - - chdir("/"); - - seteuid(0); - setegid(0); - setgid(g); - initgroups(login, g); - setuid(u); - - dtsz = getdtablesize(); - - for (i = STDERR_FILENO + 1; i < dtsz; i++) - close(i); - - execv(argv[0], argv); - _exit(EXIT_FAILURE); -} - void -load_launchd_jobs_at_loginwindow_prompt(int flags, ...) +load_launchd_jobs_at_loginwindow_prompt(int flags __attribute__((unused)), ...) { - char *largv[] = { "/bin/launchctl", "load", "-S", "LoginWindow", - "-D", "system", "-D", "local", "/etc/mach_init_per_login_session.d", NULL }; - int wstatus; - pid_t p; - - if (flags & LOAD_ONLY_SAFEMODE_LAUNCHAGENTS) { - largv[5] = "system"; - } - - if (__vproc_tag_loginwindow_context()) { - return; - } - - if ((p = fexecv_as_user("root", 0, 0, largv)) == -1) { - return; - } - - if (waitpid(p, &wstatus, 0) != p) { - return; - } + _vproc_move_subset_to_user("LoginWindow"); } pid_t -create_and_switch_to_per_session_launchd(const char *login, int flags, ...) +create_and_switch_to_per_session_launchd(const char *login __attribute__((unused)), int flags __attribute__((unused)), ...) { - char *largv[] = { "/bin/launchctl", "load", "-S", "Aqua", "-D", "all", "/etc/mach_init_per_user.d", NULL }; mach_port_t bezel_ui_server; - struct passwd *pwe; struct stat sb; - int wstatus; - pid_t p; - uid_t u; - gid_t g; - if (_vproc_move_subset_to_user()) { + if (_vproc_move_subset_to_user("Aqua")) { return -1; } - if ((pwe = getpwnam(login)) == NULL) - return -1; - - u = pwe->pw_uid; - g = pwe->pw_gid; - - if (flags & LOAD_ONLY_SAFEMODE_LAUNCHAGENTS) { - largv[5] = "system"; - } - - if ((p = fexecv_as_user(login, u, g, largv)) == -1) { - return -1; - } - - if (waitpid(p, &wstatus, 0) != p) { - return -1; - } - - if (!(WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0)) { - return -1; - } - #define BEZEL_UI_PATH "/System/Library/LoginPlugins/BezelServices.loginPlugin/Contents/Resources/BezelUI/BezelUIServer" #define BEZEL_UI_PLIST "/System/Library/LaunchAgents/com.apple.BezelUIServer.plist" #define BEZEL_UI_SERVICE "BezelUI" if (!(stat(BEZEL_UI_PLIST, &sb) == 0 && S_ISREG(sb.st_mode))) { - if (bootstrap_create_server(bootstrap_port, BEZEL_UI_PATH, u, true, &bezel_ui_server) == BOOTSTRAP_SUCCESS) { + if (bootstrap_create_server(bootstrap_port, BEZEL_UI_PATH, 0, true, &bezel_ui_server) == BOOTSTRAP_SUCCESS) { mach_port_t srv; if (bootstrap_create_service(bezel_ui_server, BEZEL_UI_SERVICE, &srv) == BOOTSTRAP_SUCCESS) { Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-03-04 17:34:05 UTC (rev 23129) +++ trunk/launchd/src/libvproc.c 2007-03-04 23:38:21 UTC (rev 23130) @@ -47,7 +47,7 @@ } vproc_err_t -_vproc_move_subset_to_user(void) +_vproc_move_subset_to_user(char *session_type) { kern_return_t kr = 1; mach_port_t puc = 0, which_port = bootstrap_port; @@ -56,7 +56,7 @@ which_port = puc; } - kr = vproc_mig_move_subset_to_user(which_port, bootstrap_port); + kr = vproc_mig_move_subset(which_port, bootstrap_port, session_type); if (puc) { mach_port_deallocate(mach_task_self(), puc); Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2007-03-04 17:34:05 UTC (rev 23129) +++ trunk/launchd/src/libvproc_internal.h 2007-03-04 23:38:21 UTC (rev 23130) @@ -57,7 +57,7 @@ kern_return_t _vprocmgr_getsocket(name_t); -vproc_err_t _vproc_move_subset_to_user(void); +vproc_err_t _vproc_move_subset_to_user(char *session_type); void _vproc_logv(int pri, int err, const char *msg, va_list ap); Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2007-03-04 17:34:05 UTC (rev 23129) +++ trunk/launchd/src/protocol_job.defs 2007-03-04 23:38:21 UTC (rev 23130) @@ -142,6 +142,7 @@ __wu : uid_t; out __u_cont : mach_port_t); -routine move_subset_to_user( +routine move_subset( __bs_port : job_t; - __target_port : mach_port_t); + __target_port : mach_port_t; + __sessiontype : name_t); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070304/b9186eeb/attachment.html From source_changes at macosforge.org Sun Mar 4 15:59:53 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23131] trunk/launchd/src Message-ID: <20070304235953.18A234C8912@cvs.opensource.apple.com> Revision: 23131 http://trac.macosforge.org/projects/launchd/changeset/23131 Author: zarzycki@apple.com Date: 2007-03-04 15:59:52 -0800 (Sun, 04 Mar 2007) Log Message: ----------- Per session launchd deployment for CLI / PAM sessions Modified Paths: -------------- trunk/launchd/src/liblaunch.c trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h trunk/launchd/src/libvproc_private.h Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2007-03-04 23:38:21 UTC (rev 23130) +++ trunk/launchd/src/liblaunch.c 2007-03-04 23:59:52 UTC (rev 23131) @@ -40,6 +40,7 @@ #include "libbootstrap_public.h" #include "libvproc_public.h" +#include "libvproc_private.h" #include "libvproc_internal.h" /* __OSBogusByteSwap__() must not really exist in the symbol namespace @@ -1163,7 +1164,7 @@ void load_launchd_jobs_at_loginwindow_prompt(int flags __attribute__((unused)), ...) { - _vproc_move_subset_to_user("LoginWindow"); + _vprocmgr_move_subset_to_user(geteuid() ? geteuid() : getuid(), "LoginWindow"); } pid_t @@ -1171,8 +1172,9 @@ { mach_port_t bezel_ui_server; struct stat sb; + uid_t target_user = geteuid() ? geteuid() : getuid(); - if (_vproc_move_subset_to_user("Aqua")) { + if (_vprocmgr_move_subset_to_user(target_user, "Aqua")) { return -1; } @@ -1181,7 +1183,7 @@ #define BEZEL_UI_SERVICE "BezelUI" if (!(stat(BEZEL_UI_PLIST, &sb) == 0 && S_ISREG(sb.st_mode))) { - if (bootstrap_create_server(bootstrap_port, BEZEL_UI_PATH, 0, true, &bezel_ui_server) == BOOTSTRAP_SUCCESS) { + if (bootstrap_create_server(bootstrap_port, BEZEL_UI_PATH, target_user, true, &bezel_ui_server) == BOOTSTRAP_SUCCESS) { mach_port_t srv; if (bootstrap_create_service(bezel_ui_server, BEZEL_UI_SERVICE, &srv) == BOOTSTRAP_SUCCESS) { Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-03-04 23:38:21 UTC (rev 23130) +++ trunk/launchd/src/libvproc.c 2007-03-04 23:59:52 UTC (rev 23131) @@ -47,12 +47,12 @@ } vproc_err_t -_vproc_move_subset_to_user(char *session_type) +_vprocmgr_move_subset_to_user(uid_t target_user, char *session_type) { kern_return_t kr = 1; mach_port_t puc = 0, which_port = bootstrap_port; - if ((getuid() || geteuid()) && vproc_mig_lookup_per_user_context(bootstrap_port, 0, &puc) == 0) { + if (target_user && vproc_mig_lookup_per_user_context(bootstrap_port, target_user, &puc) == 0) { which_port = puc; } @@ -62,7 +62,7 @@ mach_port_deallocate(mach_task_self(), puc); } - return kr == 0 ? NULL : (vproc_err_t)_vproc_move_subset_to_user; + return kr == 0 ? NULL : (vproc_err_t)_vprocmgr_move_subset_to_user; } Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2007-03-04 23:38:21 UTC (rev 23130) +++ trunk/launchd/src/libvproc_internal.h 2007-03-04 23:59:52 UTC (rev 23131) @@ -57,8 +57,6 @@ kern_return_t _vprocmgr_getsocket(name_t); -vproc_err_t _vproc_move_subset_to_user(char *session_type); - void _vproc_logv(int pri, int err, const char *msg, va_list ap); kern_return_t Modified: trunk/launchd/src/libvproc_private.h =================================================================== --- trunk/launchd/src/libvproc_private.h 2007-03-04 23:38:21 UTC (rev 23130) +++ trunk/launchd/src/libvproc_private.h 2007-03-04 23:59:52 UTC (rev 23131) @@ -20,6 +20,7 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include #include #include #include @@ -34,6 +35,8 @@ void _vproc_log(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3))); void _vproc_log_error(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3))); +vproc_err_t _vprocmgr_move_subset_to_user(uid_t target_user, char *session_type); + #pragma GCC visibility pop __END_DECLS -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070304/1222fa7b/attachment.html From source_changes at macosforge.org Sun Mar 4 19:57:17 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23132] trunk/launchd/src Message-ID: <20070305035717.D58254C8A90@cvs.opensource.apple.com> Revision: 23132 http://trac.macosforge.org/projects/launchd/changeset/23132 Author: zarzycki@apple.com Date: 2007-03-04 19:57:17 -0800 (Sun, 04 Mar 2007) Log Message: ----------- Dead code deletion. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-04 23:59:52 UTC (rev 23131) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-05 03:57:17 UTC (rev 23132) @@ -4217,9 +4217,6 @@ } switch (key) { - case GSK_LOGINWINDOW_CONTEXT: - strcpy(j->mgr->name, "LoginWindow"); - break; case GLOBAL_ON_DEMAND: kr = job_set_global_on_demand(j, (bool)val) ? 0 : 1; break; Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-03-04 23:59:52 UTC (rev 23131) +++ trunk/launchd/src/libvproc.c 2007-03-05 03:57:17 UTC (rev 23132) @@ -209,16 +209,6 @@ return (vproc_err_t)_vproc_get_last_exit_status; } -vproc_err_t -__vproc_tag_loginwindow_context(void) -{ - if (vproc_mig_set_integer(bootstrap_port, GSK_LOGINWINDOW_CONTEXT, 1) == 0) { - return NULL; - } - - return (vproc_err_t)__vproc_tag_loginwindow_context; -} - void * reboot2(uint64_t flags) { Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2007-03-04 23:59:52 UTC (rev 23131) +++ trunk/launchd/src/libvproc_internal.h 2007-03-05 03:57:17 UTC (rev 23132) @@ -31,7 +31,6 @@ typedef enum { LAST_EXIT_STATUS = 1, GLOBAL_ON_DEMAND, - GSK_LOGINWINDOW_CONTEXT, } get_set_int_key_t; #ifdef protocol_vproc_MSG_COUNT @@ -53,8 +52,6 @@ name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, mach_port_array_t *ports, mach_msg_type_number_t *portCnt); -vproc_err_t __vproc_tag_loginwindow_context(void); - kern_return_t _vprocmgr_getsocket(name_t); void _vproc_logv(int pri, int err, const char *msg, va_list ap); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070304/10d58b3f/attachment.html From source_changes at macosforge.org Mon Mar 5 08:51:50 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23133] trunk/launchd/src Message-ID: <20070305165150.0A4C14C903C@cvs.opensource.apple.com> Revision: 23133 http://trac.macosforge.org/projects/launchd/changeset/23133 Author: zarzycki@apple.com Date: 2007-03-05 08:51:49 -0800 (Mon, 05 Mar 2007) Log Message: ----------- Libraries feeding into Libsystem should contain version numbers (liblaunch) Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2007-03-05 03:57:17 UTC (rev 23132) +++ trunk/launchd/src/Makefile.am 2007-03-05 16:51:49 UTC (rev 23133) @@ -11,15 +11,19 @@ noinst_LIBRARIES = liblaunch.a liblaunch_profile.a -liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c +liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c liblaunch_profile_a_CFLAGS = -pg $(AM_CFLAGS) -liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c +liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c $(srcdir)/libvproc.c:: protocol_vproc.h $(srcdir)/protocol_vprocUser.c:: protocol_vproc.h +__version.c: + /Developer/Makefiles/bin/version.pl launchd_libs > $@ + + install-data-hook: mkdir -p $(DESTDIR)/usr/local/lib/system cp liblaunch.a $(DESTDIR)/usr/local/lib/system Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-03-05 03:57:17 UTC (rev 23132) +++ trunk/launchd/src/Makefile.in 2007-03-05 16:51:49 UTC (rev 23133) @@ -57,20 +57,22 @@ liblaunch_a_AR = $(AR) $(ARFLAGS) liblaunch_a_LIBADD = am__liblaunch_a_SOURCES_DIST = liblaunch.c libvproc.c libbootstrap.c \ - protocol_vprocUser.c + protocol_vprocUser.c __version.c @LIBS_ONLY_TRUE@am_liblaunch_a_OBJECTS = liblaunch.$(OBJEXT) \ @LIBS_ONLY_TRUE@ libvproc.$(OBJEXT) libbootstrap.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ protocol_vprocUser.$(OBJEXT) +@LIBS_ONLY_TRUE@ protocol_vprocUser.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ __version.$(OBJEXT) liblaunch_a_OBJECTS = $(am_liblaunch_a_OBJECTS) liblaunch_profile_a_AR = $(AR) $(ARFLAGS) liblaunch_profile_a_LIBADD = am__liblaunch_profile_a_SOURCES_DIST = liblaunch.c libvproc.c \ - libbootstrap.c protocol_vprocUser.c + libbootstrap.c protocol_vprocUser.c __version.c @LIBS_ONLY_TRUE@am_liblaunch_profile_a_OBJECTS = \ @LIBS_ONLY_TRUE@ liblaunch_profile_a-liblaunch.$(OBJEXT) \ @LIBS_ONLY_TRUE@ liblaunch_profile_a-libvproc.$(OBJEXT) \ @LIBS_ONLY_TRUE@ liblaunch_profile_a-libbootstrap.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ liblaunch_profile_a-protocol_vprocUser.$(OBJEXT) +@LIBS_ONLY_TRUE@ liblaunch_profile_a-protocol_vprocUser.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ liblaunch_profile_a-__version.$(OBJEXT) liblaunch_profile_a_OBJECTS = $(am_liblaunch_profile_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" \ "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(sbindir)" \ @@ -231,9 +233,9 @@ notifyServer.c notifyServer.h job_replyUser.c job_reply.h @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a -@LIBS_ONLY_TRUE@liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c +@LIBS_ONLY_TRUE@liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c @LIBS_ONLY_TRUE@liblaunch_profile_a_CFLAGS = -pg $(AM_CFLAGS) -@LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c +@LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c @LIBS_ONLY_FALSE@sbin_SCRIPTS = service @LIBS_ONLY_FALSE@sysconf_DATA = hostconfig rc.common rc.netboot @LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders @@ -423,6 +425,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-IPC.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-StartupItems.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-SystemStarter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/__version.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchctl-launchctl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-job_replyUser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd.Po@am__quote@ @@ -436,6 +439,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchproxy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbootstrap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-__version.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-libbootstrap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-liblaunch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-libvproc.Po@am__quote@ @@ -514,6 +518,20 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-protocol_vprocUser.obj `if test -f 'protocol_vprocUser.c'; then $(CYGPATH_W) 'protocol_vprocUser.c'; else $(CYGPATH_W) '$(srcdir)/protocol_vprocUser.c'; fi` +liblaunch_profile_a-__version.o: __version.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-__version.o -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-__version.Tpo" -c -o liblaunch_profile_a-__version.o `test -f '__version.c' || echo '$(srcdir)/'`__version.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-__version.Tpo" "$(DEPDIR)/liblaunch_profile_a-__version.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-__version.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='__version.c' object='liblaunch_profile_a-__version.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-__version.o `test -f '__version.c' || echo '$(srcdir)/'`__version.c + +liblaunch_profile_a-__version.obj: __version.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-__version.obj -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-__version.Tpo" -c -o liblaunch_profile_a-__version.obj `if test -f '__version.c'; then $(CYGPATH_W) '__version.c'; else $(CYGPATH_W) '$(srcdir)/__version.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-__version.Tpo" "$(DEPDIR)/liblaunch_profile_a-__version.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-__version.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='__version.c' object='liblaunch_profile_a-__version.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-__version.obj `if test -f '__version.c'; then $(CYGPATH_W) '__version.c'; else $(CYGPATH_W) '$(srcdir)/__version.c'; fi` + SystemStarter-StartupItems.o: StartupItems.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(SystemStarter_CFLAGS) $(CFLAGS) -MT SystemStarter-StartupItems.o -MD -MP -MF "$(DEPDIR)/SystemStarter-StartupItems.Tpo" -c -o SystemStarter-StartupItems.o `test -f 'StartupItems.c' || echo '$(srcdir)/'`StartupItems.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/SystemStarter-StartupItems.Tpo" "$(DEPDIR)/SystemStarter-StartupItems.Po"; else rm -f "$(DEPDIR)/SystemStarter-StartupItems.Tpo"; exit 1; fi @@ -1040,6 +1058,9 @@ @LIBS_ONLY_TRUE@$(srcdir)/protocol_vprocUser.c:: protocol_vproc.h +@LIBS_ONLY_TRUE@__version.c: +@LIBS_ONLY_TRUE@ /Developer/Makefiles/bin/version.pl launchd_libs > $@ + @LIBS_ONLY_TRUE@install-data-hook: @LIBS_ONLY_TRUE@ mkdir -p $(DESTDIR)/usr/local/lib/system @LIBS_ONLY_TRUE@ cp liblaunch.a $(DESTDIR)/usr/local/lib/system -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070305/9d14cafb/attachment.html From source_changes at macosforge.org Mon Mar 5 08:52:51 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23134] trunk/launchd/src Message-ID: <20070305165251.415ED4C9048@cvs.opensource.apple.com> Revision: 23134 http://trac.macosforge.org/projects/launchd/changeset/23134 Author: zarzycki@apple.com Date: 2007-03-05 08:52:51 -0800 (Mon, 05 Mar 2007) Log Message: ----------- Let's not leave junk around. Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2007-03-05 16:51:49 UTC (rev 23133) +++ trunk/launchd/src/Makefile.am 2007-03-05 16:52:51 UTC (rev 23134) @@ -2,7 +2,7 @@ CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ - notifyServer.c notifyServer.h job_replyUser.c job_reply.h + notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h: $(srcdir)/protocol_job.defs mig $(MIGFLAGS) -sheader protocol_vprocServer.h $(srcdir)/protocol_job.defs Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-03-05 16:51:49 UTC (rev 23133) +++ trunk/launchd/src/Makefile.in 2007-03-05 16:52:51 UTC (rev 23134) @@ -230,7 +230,7 @@ AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ - notifyServer.c notifyServer.h job_replyUser.c job_reply.h + notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a @LIBS_ONLY_TRUE@liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070305/ffc468ea/attachment.html From source_changes at macosforge.org Mon Mar 5 13:40:38 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23135] tags/launchd-201/ Message-ID: <20070305214038.C6C8A4C961B@cvs.opensource.apple.com> Revision: 23135 http://trac.macosforge.org/projects/launchd/changeset/23135 Author: zarzycki@apple.com Date: 2007-03-05 13:40:38 -0800 (Mon, 05 Mar 2007) Log Message: ----------- "Tagging launchd-201 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-201/ Copied: tags/launchd-201 (from rev 23134, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070305/668efa3b/attachment.html From source_changes at macosforge.org Tue Mar 6 11:22:51 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23136] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070306192251.75DB14CB5D8@cvs.opensource.apple.com> Revision: 23136 http://trac.macosforge.org/projects/launchd/changeset/23136 Author: zarzycki@apple.com Date: 2007-03-06 11:22:51 -0800 (Tue, 06 Mar 2007) Log Message: ----------- launchd-201: can't ssh in with AFP OD account (hangs) 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-03-05 21:40:38 UTC (rev 23135) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-06 19:22:51 UTC (rev 23136) @@ -3487,7 +3487,12 @@ if (name) { /* no name implies: bootstrap_subset() where creating a "bootstrapper" makes no sense */ bootstrapper = job_new(jmr, "com.apple.launchctld", NULL, bootstrap_tool); - if (jm || getuid()) { + if (jobmgr_assumes(jmr, bootstrapper != NULL) && (jm || getuid())) { + char buf[100]; + + /* launchd-201: can't ssh in with AFP OD account (hangs) */ + snprintf(buf, sizeof(buf), "0x%X:0:0", getuid()); + envitem_new(bootstrapper, "__CF_USER_TEXT_ENCODING", buf, false); bootstrapper->weird_bootstrap = true; jobmgr_assumes(jmr, job_setup_machport(bootstrapper)); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070306/948909d2/attachment.html From source_changes at macosforge.org Tue Mar 6 13:38:02 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23137] tags/launchd-202/ Message-ID: <20070306213802.BE9BD4CB7AA@cvs.opensource.apple.com> Revision: 23137 http://trac.macosforge.org/projects/launchd/changeset/23137 Author: zarzycki@apple.com Date: 2007-03-06 13:38:02 -0800 (Tue, 06 Mar 2007) Log Message: ----------- "Tagging launchd-202 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-202/ Copied: tags/launchd-202 (from rev 23136, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070306/b542bb28/attachment.html From source_changes at macosforge.org Tue Mar 6 16:32:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23138] trunk/launchd Message-ID: <20070307003249.5EE904CBB34@cvs.opensource.apple.com> Revision: 23138 http://trac.macosforge.org/projects/launchd/changeset/23138 Author: zarzycki@apple.com Date: 2007-03-06 16:32:48 -0800 (Tue, 06 Mar 2007) Log Message: ----------- Supply an API for CoreFoundation to get the PID of the per user launchd Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_mig_types.defs trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h trunk/launchd/src/libvproc_public.h trunk/launchd/src/protocol_job.defs Added Paths: ----------- trunk/launchd/testing/vproc_gsk_test.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-06 21:38:02 UTC (rev 23137) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-07 00:32:48 UTC (rev 23138) @@ -4170,7 +4170,7 @@ } kern_return_t -job_mig_get_integer(job_t j, get_set_int_key_t key, int64_t *val) +job_mig_swap_integer(job_t j, vproc_gsk_t inkey, vproc_gsk_t outkey, int64_t inval, int64_t *outval) { kern_return_t kr = 0; @@ -4178,15 +4178,38 @@ return BOOTSTRAP_NO_MEMORY; } - switch (key) { - case LAST_EXIT_STATUS: - *val = j->last_exit_status; + switch (outkey) { + case VPROC_GSK_LAST_EXIT_STATUS: + *outval = j->last_exit_status; break; + case VPROC_GSK_MGR_UID: + *outval = getuid(); + break; + case VPROC_GSK_MGR_PID: + *outval = getpid(); + break; + case 0: + *outval = 0; + break; default: kr = 1; break; } + switch (inkey) { + case VPROC_GSK_GLOBAL_ON_DEMAND: + kr = job_set_global_on_demand(j, (bool)inval) ? 0 : 1; + break; + case 0: + break; + case VPROC_GSK_LAST_EXIT_STATUS: + case VPROC_GSK_MGR_UID: + case VPROC_GSK_MGR_PID: + default: + kr = 1; + break; + } + return kr; } @@ -4213,27 +4236,6 @@ } kern_return_t -job_mig_set_integer(job_t j, get_set_int_key_t key, int64_t val) -{ - kern_return_t kr = 0; - - if (!launchd_assumes(j != NULL)) { - return BOOTSTRAP_NO_MEMORY; - } - - switch (key) { - case GLOBAL_ON_DEMAND: - kr = job_set_global_on_demand(j, (bool)val) ? 0 : 1; - break; - default: - kr = 1; - break; - } - - return kr; -} - -kern_return_t job_mig_getsocket(job_t j, name_t spr) { if (!launchd_assumes(j != NULL)) { Modified: trunk/launchd/src/launchd_mig_types.defs =================================================================== --- trunk/launchd/src/launchd_mig_types.defs 2007-03-06 21:38:02 UTC (rev 23137) +++ trunk/launchd/src/launchd_mig_types.defs 2007-03-07 00:32:48 UTC (rev 23138) @@ -26,7 +26,7 @@ type pid_t = integer_t; type uid_t = integer_t; type gid_t = integer_t; -type get_set_int_key_t = integer_t; +type vproc_gsk_t = integer_t; type logmsg_t = c_string[*:2048]; type cmd_t = c_string[512]; type cmd_array_t = ^array [] of cmd_t; Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-03-06 21:38:02 UTC (rev 23137) +++ trunk/launchd/src/libvproc.c 2007-03-07 00:32:48 UTC (rev 23138) @@ -201,7 +201,7 @@ { int64_t val; - if (vproc_mig_get_integer(bootstrap_port, LAST_EXIT_STATUS, &val) == 0) { + if (vproc_swap_integer(NULL, VPROC_GSK_LAST_EXIT_STATUS, 0, &val) == 0) { *wstatus = (int)val; return NULL; } @@ -209,6 +209,18 @@ return (vproc_err_t)_vproc_get_last_exit_status; } +vproc_err_t +vproc_swap_integer(vproc_t vp __attribute__((unused)), vproc_gsk_t key, int64_t *inval, int64_t *outval) +{ + int64_t dummyval = 0; + + if (vproc_mig_swap_integer(bootstrap_port, inval ? key : 0, outval ? key : 0, inval ? *inval : 0, outval ? outval : &dummyval) == 0) { + return NULL; + } + + return (vproc_err_t)vproc_swap_integer; +} + void * reboot2(uint64_t flags) { @@ -242,7 +254,7 @@ { int64_t val = state ? ~0 : 0; - if (vproc_mig_set_integer(bootstrap_port, GLOBAL_ON_DEMAND, val) == 0) { + if (vproc_swap_integer(NULL, VPROC_GSK_GLOBAL_ON_DEMAND, &val, NULL) == 0) { return NULL; } Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2007-03-06 21:38:02 UTC (rev 23137) +++ trunk/launchd/src/libvproc_internal.h 2007-03-07 00:32:48 UTC (rev 23138) @@ -28,10 +28,6 @@ typedef char * logmsg_t; typedef mach_port_t vproc_mig_t; typedef integer_t binpref_t[8]; -typedef enum { - LAST_EXIT_STATUS = 1, - GLOBAL_ON_DEMAND, -} get_set_int_key_t; #ifdef protocol_vproc_MSG_COUNT /* HACK */ Modified: trunk/launchd/src/libvproc_public.h =================================================================== --- trunk/launchd/src/libvproc_public.h 2007-03-06 21:38:02 UTC (rev 23137) +++ trunk/launchd/src/libvproc_public.h 2007-03-07 00:32:48 UTC (rev 23138) @@ -21,16 +21,30 @@ */ #include +#include __BEGIN_DECLS +#pragma GCC visibility push(default) + +typedef enum { + VPROC_GSK_LAST_EXIT_STATUS = 1, + VPROC_GSK_GLOBAL_ON_DEMAND, + VPROC_GSK_MGR_UID, + VPROC_GSK_MGR_PID, +} vproc_gsk_t; + typedef void * vproc_err_t; typedef void * vproc_t; typedef void * vprocmgr_t; +vproc_err_t vproc_swap_integer(vproc_t vp, vproc_gsk_t key, int64_t *inval, int64_t *outval); + const char *vproc_strerror(vproc_err_t r); +#pragma GCC visibility pop + __END_DECLS #endif Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2007-03-06 21:38:02 UTC (rev 23137) +++ trunk/launchd/src/protocol_job.defs 2007-03-07 00:32:48 UTC (rev 23138) @@ -121,15 +121,14 @@ routine uncork_fork( __bs_port : job_t); -routine get_integer( +routine swap_integer( __bs_port : job_t; - __key : get_set_int_key_t; - out __val : int64_t); + __inkey : vproc_gsk_t; + __outkey : vproc_gsk_t; + __inval : int64_t; + out __outval : int64_t); -routine set_integer( - __bs_port : job_t; - __key : get_set_int_key_t; - __val : int64_t); +skip; simpleroutine log( __bs_port : job_t; Added: trunk/launchd/testing/vproc_gsk_test.c =================================================================== --- trunk/launchd/testing/vproc_gsk_test.c (rev 0) +++ trunk/launchd/testing/vproc_gsk_test.c 2007-03-07 00:32:48 UTC (rev 23138) @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +int main(void) +{ + int64_t val; + pid_t p; + uid_t u; + + /* we assign val to p or u due to 64 bit to 32 bit trucation */ + + assert(vproc_swap_integer(NULL, VPROC_GSK_MGR_PID, NULL, &val) == NULL); + p = val; + + assert(vproc_swap_integer(NULL, VPROC_GSK_MGR_UID, NULL, &val) == NULL); + u = val; + + fprintf(stdout, "UID = %u PID = %u\n", u, p); + + return 0; +} -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070306/2ebcdc66/attachment.html From source_changes at macosforge.org Tue Mar 6 16:39:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23139] trunk/launchd Message-ID: <20070307003949.634934CBB5D@cvs.opensource.apple.com> Revision: 23139 http://trac.macosforge.org/projects/launchd/changeset/23139 Author: zarzycki@apple.com Date: 2007-03-06 16:39:48 -0800 (Tue, 06 Mar 2007) Log Message: ----------- launchd needs to supply SPI for CFLog/NSLog to use for determining provenance of stderr Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc_public.h trunk/launchd/testing/vproc_gsk_test.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-07 00:32:48 UTC (rev 23138) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-07 00:39:48 UTC (rev 23139) @@ -4188,6 +4188,9 @@ case VPROC_GSK_MGR_PID: *outval = getpid(); break; + case VPROC_GSK_IS_NATIVE: + *outval = !j->anonymous; + break; case 0: *outval = 0; break; @@ -4202,6 +4205,7 @@ break; case 0: break; + case VPROC_GSK_IS_NATIVE: case VPROC_GSK_LAST_EXIT_STATUS: case VPROC_GSK_MGR_UID: case VPROC_GSK_MGR_PID: Modified: trunk/launchd/src/libvproc_public.h =================================================================== --- trunk/launchd/src/libvproc_public.h 2007-03-07 00:32:48 UTC (rev 23138) +++ trunk/launchd/src/libvproc_public.h 2007-03-07 00:39:48 UTC (rev 23139) @@ -32,6 +32,7 @@ VPROC_GSK_GLOBAL_ON_DEMAND, VPROC_GSK_MGR_UID, VPROC_GSK_MGR_PID, + VPROC_GSK_IS_NATIVE, } vproc_gsk_t; typedef void * vproc_err_t; Modified: trunk/launchd/testing/vproc_gsk_test.c =================================================================== --- trunk/launchd/testing/vproc_gsk_test.c 2007-03-07 00:32:48 UTC (rev 23138) +++ trunk/launchd/testing/vproc_gsk_test.c 2007-03-07 00:39:48 UTC (rev 23139) @@ -6,6 +6,7 @@ int main(void) { int64_t val; + bool is_native; pid_t p; uid_t u; @@ -17,7 +18,10 @@ assert(vproc_swap_integer(NULL, VPROC_GSK_MGR_UID, NULL, &val) == NULL); u = val; - fprintf(stdout, "UID = %u PID = %u\n", u, p); + assert(vproc_swap_integer(NULL, VPROC_GSK_IS_NATIVE, NULL, &val) == NULL); + is_native = val; + fprintf(stdout, "UID = %u PID = %u Native = %u\n", u, p, is_native); + return 0; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070306/3902cd47/attachment.html From source_changes at macosforge.org Tue Mar 6 16:45:45 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23140] trunk/launchd/src Message-ID: <20070307004545.1D7374CBB7C@cvs.opensource.apple.com> Revision: 23140 http://trac.macosforge.org/projects/launchd/changeset/23140 Author: zarzycki@apple.com Date: 2007-03-06 16:45:44 -0800 (Tue, 06 Mar 2007) Log Message: ----------- Let jobs tweak their basic keepalive bit on the fly. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc_public.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-07 00:39:48 UTC (rev 23139) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-07 00:45:44 UTC (rev 23140) @@ -4191,6 +4191,9 @@ case VPROC_GSK_IS_NATIVE: *outval = !j->anonymous; break; + case VPROC_GSK_BASIC_KEEPALIVE: + *outval = !j->ondemand; + break; case 0: *outval = 0; break; @@ -4203,6 +4206,9 @@ case VPROC_GSK_GLOBAL_ON_DEMAND: kr = job_set_global_on_demand(j, (bool)inval) ? 0 : 1; break; + case VPROC_GSK_BASIC_KEEPALIVE: + j->ondemand = !inval; + break; case 0: break; case VPROC_GSK_IS_NATIVE: Modified: trunk/launchd/src/libvproc_public.h =================================================================== --- trunk/launchd/src/libvproc_public.h 2007-03-07 00:39:48 UTC (rev 23139) +++ trunk/launchd/src/libvproc_public.h 2007-03-07 00:45:44 UTC (rev 23140) @@ -33,6 +33,7 @@ VPROC_GSK_MGR_UID, VPROC_GSK_MGR_PID, VPROC_GSK_IS_NATIVE, + VPROC_GSK_BASIC_KEEPALIVE, } vproc_gsk_t; typedef void * vproc_err_t; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070306/0c90ddd5/attachment.html From source_changes at macosforge.org Tue Mar 6 16:54:30 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23141] trunk/launchd/src Message-ID: <20070307005430.7FC6A4CBBA3@cvs.opensource.apple.com> Revision: 23141 http://trac.macosforge.org/projects/launchd/changeset/23141 Author: zarzycki@apple.com Date: 2007-03-06 16:54:30 -0800 (Tue, 06 Mar 2007) Log Message: ----------- Allow jobs to tweak their basic start interval at runtime. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc_public.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-07 00:45:44 UTC (rev 23140) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-07 00:54:30 UTC (rev 23141) @@ -4194,6 +4194,9 @@ case VPROC_GSK_BASIC_KEEPALIVE: *outval = !j->ondemand; break; + case VPROC_GSK_START_INTERVAL: + *outval = j->start_interval; + break; case 0: *outval = 0; break; @@ -4209,6 +4212,15 @@ case VPROC_GSK_BASIC_KEEPALIVE: j->ondemand = !inval; break; + case VPROC_GSK_START_INTERVAL: + if ((unsigned int)inval > 0) { + j->start_interval = inval; + job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, j->start_interval, j) != -1); + } else if (j->start_interval) { + job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); + j->start_interval = 0; + } + break; case 0: break; case VPROC_GSK_IS_NATIVE: Modified: trunk/launchd/src/libvproc_public.h =================================================================== --- trunk/launchd/src/libvproc_public.h 2007-03-07 00:45:44 UTC (rev 23140) +++ trunk/launchd/src/libvproc_public.h 2007-03-07 00:54:30 UTC (rev 23141) @@ -34,6 +34,7 @@ VPROC_GSK_MGR_PID, VPROC_GSK_IS_NATIVE, VPROC_GSK_BASIC_KEEPALIVE, + VPROC_GSK_START_INTERVAL, } vproc_gsk_t; typedef void * vproc_err_t; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070306/18dba0b9/attachment.html From source_changes at macosforge.org Wed Mar 7 09:44:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23142] trunk/launchd/src/launchctl.c Message-ID: <20070307174429.7F7084CCB96@cvs.opensource.apple.com> Revision: 23142 http://trac.macosforge.org/projects/launchd/changeset/23142 Author: zarzycki@apple.com Date: 2007-03-07 09:44:28 -0800 (Wed, 07 Mar 2007) Log Message: ----------- Dead code deletion. Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-03-07 00:54:30 UTC (rev 23141) +++ trunk/launchd/src/launchctl.c 2007-03-07 17:44:28 UTC (rev 23142) @@ -1355,11 +1355,9 @@ _vproc_set_global_on_demand(false); - if (!path_check("/System/Library/LoginPlugins/BootCache.loginPlugin")) { - assumes(kevent(kq, NULL, 0, &kev, 1, NULL) == 1); + assumes(kevent(kq, NULL, 0, &kev, 1, NULL) == 1); - do_BootCache_magic(BOOTCACHE_STOP); - } + do_BootCache_magic(BOOTCACHE_STOP); assumes(close(kq) != -1); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070307/2610dbe9/attachment.html From source_changes at macosforge.org Wed Mar 7 10:01:26 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23143] trunk/launchd/src/launchctl.c Message-ID: <20070307180126.F26434CCBBB@cvs.opensource.apple.com> Revision: 23143 http://trac.macosforge.org/projects/launchd/changeset/23143 Author: zarzycki@apple.com Date: 2007-03-07 10:01:26 -0800 (Wed, 07 Mar 2007) Log Message: ----------- Wow, I don't touch launchctl.c enough. My style has changed over time. (Always use {}, you're going to need them eventually, and when you do, it makes for a more clear diff.) Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-03-07 17:44:28 UTC (rev 23142) +++ trunk/launchd/src/launchctl.c 2007-03-07 18:01:26 UTC (rev 23143) @@ -278,8 +278,9 @@ optreset = 1; for (i = 0; i < (sizeof cmds / sizeof cmds[0]); i++) { - if (!strcmp(cmds[i].name, argv[0])) + if (!strcmp(cmds[i].name, argv[0])) { return cmds[i].func(argc, argv); + } } fprintf(stderr, "%s: unknown subcommand \"%s\"\n", getprogname(), argv[0]); @@ -349,10 +350,11 @@ bool *is_csh = context; /* XXX escape the double quotes */ - if (*is_csh) + if (*is_csh) { fprintf(stdout, "setenv %s \"%s\";\n", key, launch_data_get_string(obj)); - else + } else { fprintf(stdout, "%s=\"%s\"; export %s;\n", key, launch_data_get_string(obj), key); + } } void @@ -360,8 +362,9 @@ { const char *k = context; - if (!strcmp(key, k)) + if (!strcmp(key, k)) { fprintf(stdout, "%s\n", launch_data_get_string(obj)); + } } int @@ -373,8 +376,9 @@ if (!strcmp(argv[0], "export")) { char *s = getenv("SHELL"); - if (s) + if (s) { is_csh = strstr(s, "csh") ? true : false; + } } else if (argc != 2) { fprintf(stderr, "%s usage: getenv \n", getprogname()); return 1; @@ -388,10 +392,11 @@ launch_data_free(msg); if (resp) { - if (!strcmp(argv[0], "export")) + if (!strcmp(argv[0], "export")) { launch_data_dict_iterate(resp, print_launchd_env, &is_csh); - else + } else { launch_data_dict_iterate(resp, print_key_value, k); + } launch_data_free(resp); } else { fprintf(stderr, "launch_msg(\"" LAUNCH_KEY_GETUSERENVIRONMENT "\"): %s\n", strerror(errno)); @@ -423,8 +428,9 @@ return; } if (LAUNCH_DATA_ERRNO == launch_data_get_type(resp)) { - if ((e = launch_data_get_errno(resp))) + if ((e = launch_data_get_errno(resp))) { fprintf(stderr, "%s\n", strerror(e)); + } } launch_data_free(resp); } @@ -441,10 +447,11 @@ } if (editondisk) { - if (load) + if (load) { CFDictionaryRemoveValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED)); - else + } else { CFDictionarySetValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED), kCFBooleanTrue); + } WriteMyPropertyListToFile(plist, file); } @@ -471,8 +478,9 @@ launch_data_dict_iterate(o, delay_to_second_pass2, context); break; case LAUNCH_DATA_ARRAY: - for (i = 0; i < launch_data_array_get_count(o); i++) + for (i = 0; i < launch_data_array_get_count(o); i++) { delay_to_second_pass2(launch_data_array_get_index(o, i), NULL, context); + } break; default: break; @@ -486,8 +494,9 @@ launch_data_t socks = launch_data_dict_lookup(o, LAUNCH_JOBKEY_SOCKETS); - if (NULL == socks) + if (NULL == socks) { return false; + } delay_to_second_pass2(socks, NULL, &res); @@ -525,8 +534,9 @@ for (i = 0; i < c; i++) { launch_data_t oai = launch_data_array_get_index(tmpa, i); - if (!strcasecmp(ourhostname, launch_data_get_string(oai))) + if (!strcasecmp(ourhostname, launch_data_get_string(oai))) { goto out_bad; + } } } @@ -535,12 +545,14 @@ for (i = 0; i < c; i++) { launch_data_t oai = launch_data_array_get_index(tmpa, i); - if (!strcasecmp(ourhostname, launch_data_get_string(oai))) + if (!strcasecmp(ourhostname, launch_data_get_string(oai))) { break; + } } - if (i == c) + if (i == c) { goto out_bad; + } } if (lus->session_type && !(tmpa = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE))) { @@ -582,27 +594,33 @@ } } - if ((tmpd = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_DISABLED))) + if ((tmpd = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_DISABLED))) { job_disabled = launch_data_get_bool(tmpd); + } - if (lus->forceload) + if (lus->forceload) { job_disabled = false; + } - if (job_disabled && lus->load) + if (job_disabled && lus->load) { goto out_bad; + } - if (delay_to_second_pass(thejob)) + if (delay_to_second_pass(thejob)) { launch_data_array_append(lus->pass2, thejob); - else + } else { launch_data_array_append(lus->pass1, thejob); + } - if (verbose) + if (verbose) { fprintf(stdout, "Will load: %s\n", what); + } return; out_bad: - if (verbose) + if (verbose) { fprintf(stdout, "Ignored: %s\n", what); + } launch_data_free(thejob); } @@ -616,8 +634,9 @@ return false; } - if (forceload) + if (forceload) { return true; + } if (sb.st_mode & (S_IWOTH|S_IWGRP)) { fprintf(stderr, "%s: Dubious permissions on file (skipping): %s\n", getprogname(), path); @@ -645,11 +664,13 @@ struct dirent *de; DIR *d; - if (!path_goodness_check(what, lus->forceload)) + if (!path_goodness_check(what, lus->forceload)) { return; + } - if (stat(what, &sb) == -1) + if (stat(what, &sb) == -1) { return; + } if (S_ISREG(sb.st_mode)) { readfile(what, lus); @@ -660,12 +681,14 @@ } while ((de = readdir(d))) { - if ((de->d_name[0] == '.')) + if ((de->d_name[0] == '.')) { continue; + } snprintf(buf, sizeof(buf), "%s/%s", what, de->d_name); - if (!path_goodness_check(buf, lus->forceload)) + if (!path_goodness_check(buf, lus->forceload)) { continue; + } readfile(buf, lus); } @@ -738,8 +761,9 @@ } } - if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_PASSIVE))) + if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_PASSIVE))) { passive = launch_data_get_bool(val); + } if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_SECUREWITHKEY))) { char secdir[] = LAUNCH_SECDIR, buf[1024]; @@ -772,8 +796,9 @@ strncpy(sun.sun_path, launch_data_get_string(val), sizeof(sun.sun_path)); - if ((sfd = _fd(socket(AF_UNIX, st, 0))) == -1) + if ((sfd = _fd(socket(AF_UNIX, st, 0))) == -1) { return; + } if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_PATHMODE))) { sun_mode = (mode_t)launch_data_get_integer(val); @@ -795,8 +820,7 @@ if (setm) { chmod(sun.sun_path, sun_mode); } - if ((st == SOCK_STREAM || st == SOCK_SEQPACKET) - && listen(sfd, SOMAXCONN) == -1) { + if ((st == SOCK_STREAM || st == SOCK_SEQPACKET) && listen(sfd, SOMAXCONN) == -1) { close(sfd); return; } @@ -818,13 +842,16 @@ memset(&hints, 0, sizeof(hints)); hints.ai_socktype = st; - if (passive) + if (passive) { hints.ai_flags |= AI_PASSIVE; + } - if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_NODENAME))) + if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_NODENAME))) { node = launch_data_get_string(val); - if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_MULTICASTGROUP))) + } + if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_MULTICASTGROUP))) { mgroup = launch_data_get_string(val); + } if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_SERVICENAME))) { if (LAUNCH_DATA_INTEGER == launch_data_get_type(val)) { sprintf(servnbuf, "%lld", launch_data_get_integer(val)); @@ -834,10 +861,11 @@ } } if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_FAMILY))) { - if (!strcasecmp("IPv4", launch_data_get_string(val))) + if (!strcasecmp("IPv4", launch_data_get_string(val))) { hints.ai_family = AF_INET; - else if (!strcasecmp("IPv6", launch_data_get_string(val))) + } else if (!strcasecmp("IPv6", launch_data_get_string(val))) { hints.ai_family = AF_INET6; + } } if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_PROTOCOL))) { if (!strcasecmp("TCP", launch_data_get_string(val))) { @@ -900,8 +928,7 @@ if (mgroup) { do_mgroup_join(sfd, res->ai_family, res->ai_socktype, res->ai_protocol, mgroup); } - if ((res->ai_socktype == SOCK_STREAM || res->ai_socktype == SOCK_SEQPACKET) - && listen(sfd, SOMAXCONN) == -1) { + if ((res->ai_socktype == SOCK_STREAM || res->ai_socktype == SOCK_SEQPACKET) && listen(sfd, SOMAXCONN) == -1) { fprintf(stderr, "listen(): %s\n", strerror(errno)); return; } @@ -914,12 +941,14 @@ } if (NULL == rnames) { rvs_fd = do_rendezvous_magic(res, serv); - if (rvs_fd) + if (rvs_fd) { launch_data_array_append(rvs_fds, rvs_fd); + } } else if (LAUNCH_DATA_STRING == launch_data_get_type(rnames)) { rvs_fd = do_rendezvous_magic(res, launch_data_get_string(rnames)); - if (rvs_fd) + if (rvs_fd) { launch_data_array_append(rvs_fds, rvs_fd); + } } else if (LAUNCH_DATA_ARRAY == launch_data_get_type(rnames)) { size_t rn_i, rn_ac = launch_data_array_get_count(rnames); @@ -927,8 +956,9 @@ launch_data_t rn_tmp = launch_data_array_get_index(rnames, rn_i); rvs_fd = do_rendezvous_magic(res, launch_data_get_string(rn_tmp)); - if (rvs_fd) + if (rvs_fd) { launch_data_array_append(rvs_fds, rvs_fd); + } } } } @@ -1006,23 +1036,27 @@ short port; static int statres = 1; - if (1 == statres) + if (1 == statres) { statres = stat("/usr/sbin/mDNSResponder", &sb); + } - if (-1 == statres) + if (-1 == statres) { return NULL; + } sprintf(rvs_buf, "_%s._%s.", serv, res->ai_socktype == SOCK_STREAM ? "tcp" : "udp"); - if (res->ai_family == AF_INET) + if (res->ai_family == AF_INET) { port = ((struct sockaddr_in *)res->ai_addr)->sin_port; - else + } else { port = ((struct sockaddr_in6 *)res->ai_addr)->sin6_port; + } error = DNSServiceRegister(&service, 0, 0, NULL, rvs_buf, NULL, NULL, port, 0, NULL, NULL, NULL); - if (error == kDNSServiceErr_NoError) + if (error == kDNSServiceErr_NoError) { return launch_data_new_fd(DNSServiceRefSockFD(service)); + } fprintf(stderr, "DNSServiceRegister(\"%s\"): %d\n", serv, error); return NULL; @@ -1038,13 +1072,16 @@ CFURLRef fileURL; fileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)posixfile, strlen(posixfile), false); - if (!fileURL) + if (!fileURL) { fprintf(stderr, "%s: CFURLCreateFromFileSystemRepresentation(%s) failed\n", getprogname(), posixfile); - if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, fileURL, &resourceData, NULL, NULL, &errorCode)) + } + if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, fileURL, &resourceData, NULL, NULL, &errorCode)) { fprintf(stderr, "%s: CFURLCreateDataAndPropertiesFromResource(%s) failed: %d\n", getprogname(), posixfile, (int)errorCode); + } propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resourceData, kCFPropertyListMutableContainers, &errorString); - if (!propertyList) + if (!propertyList) { fprintf(stderr, "%s: propertyList is NULL\n", getprogname()); + } return propertyList; } @@ -1057,13 +1094,16 @@ SInt32 errorCode; fileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)posixfile, strlen(posixfile), false); - if (!fileURL) + if (!fileURL) { fprintf(stderr, "%s: CFURLCreateFromFileSystemRepresentation(%s) failed\n", getprogname(), posixfile); + } resourceData = CFPropertyListCreateXMLData(kCFAllocatorDefault, plist); - if (resourceData == NULL) + if (resourceData == NULL) { fprintf(stderr, "%s: CFPropertyListCreateXMLData(%s) failed", getprogname(), posixfile); - if (!CFURLWriteDataAndPropertiesToResource(fileURL, resourceData, NULL, &errorCode)) + } + if (!CFURLWriteDataAndPropertiesToResource(fileURL, resourceData, NULL, &errorCode)) { fprintf(stderr, "%s: CFURLWriteDataAndPropertiesToResource(%s) failed: %d\n", getprogname(), posixfile, (int)errorCode); + } } void @@ -1162,8 +1202,9 @@ cmdwidth = l; } - for (i = 0; i < (sizeof cmds / sizeof cmds[0]); i++) + for (i = 0; i < (sizeof cmds / sizeof cmds[0]); i++) { fprintf(where, "\t%-*s\t%s\n", cmdwidth, cmds[i].name, cmds[i].desc); + } return 0; } @@ -1564,10 +1605,12 @@ distill_jobs(lus.pass2); submit_job_pass(lus.pass2); } else { - for (i = 0; i < launch_data_array_get_count(lus.pass1); i++) + for (i = 0; i < launch_data_array_get_count(lus.pass1); i++) { unloadjob(launch_data_array_get_index(lus.pass1, i)); - for (i = 0; i < launch_data_array_get_count(lus.pass2); i++) + } + for (i = 0; i < launch_data_array_get_count(lus.pass2); i++) { unloadjob(launch_data_array_get_index(lus.pass2, i)); + } } return 0; @@ -2762,18 +2805,21 @@ return; while ((val = fgetln(sf, &ln_len))) { - if (ln_len == 0) + if (ln_len == 0) { continue; - if (!assumes((tmpstr = malloc(ln_len + 1)) != NULL)) + } + if (!assumes((tmpstr = malloc(ln_len + 1)) != NULL)) { continue; + } memcpy(tmpstr, val, ln_len); tmpstr[ln_len] = 0; val = tmpstr; while (*val && isspace(*val)) val++; - if (*val == '\0' || *val == '#') + if (*val == '\0' || *val == '#') { goto skip_sysctl_tool; + } sysctl_tool[2] = val; assumes(fwexec(sysctl_tool, true) != -1); skip_sysctl_tool: @@ -2799,8 +2845,9 @@ return; } - if (buf[0] != '\0') + if (buf[0] != '\0') { return; + } versdict = _CFCopySystemVersionDictionary(); buildvers = CFDictionaryGetValue(versdict, _kCFSystemVersionBuildVersionKey); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070307/4a025a0f/attachment.html From source_changes at macosforge.org Wed Mar 7 14:50:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23144] trunk/launchd/src Message-ID: <20070307225049.8168E4CD249@cvs.opensource.apple.com> Revision: 23144 http://trac.macosforge.org/projects/launchd/changeset/23144 Author: zarzycki@apple.com Date: 2007-03-07 14:50:49 -0800 (Wed, 07 Mar 2007) Log Message: ----------- Make the get-set-key API private. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc_private.h trunk/launchd/src/libvproc_public.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-07 18:01:26 UTC (rev 23143) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-07 22:50:49 UTC (rev 23144) @@ -4188,7 +4188,7 @@ case VPROC_GSK_MGR_PID: *outval = getpid(); break; - case VPROC_GSK_IS_NATIVE: + case VPROC_GSK_IS_MANAGED: *outval = !j->anonymous; break; case VPROC_GSK_BASIC_KEEPALIVE: @@ -4223,7 +4223,7 @@ break; case 0: break; - case VPROC_GSK_IS_NATIVE: + case VPROC_GSK_IS_MANAGED: case VPROC_GSK_LAST_EXIT_STATUS: case VPROC_GSK_MGR_UID: case VPROC_GSK_MGR_PID: Modified: trunk/launchd/src/libvproc_private.h =================================================================== --- trunk/launchd/src/libvproc_private.h 2007-03-07 18:01:26 UTC (rev 23143) +++ trunk/launchd/src/libvproc_private.h 2007-03-07 22:50:49 UTC (rev 23144) @@ -29,6 +29,18 @@ #pragma GCC visibility push(default) +typedef enum { + VPROC_GSK_LAST_EXIT_STATUS = 1, + VPROC_GSK_GLOBAL_ON_DEMAND, + VPROC_GSK_MGR_UID, + VPROC_GSK_MGR_PID, + VPROC_GSK_IS_MANAGED, + VPROC_GSK_BASIC_KEEPALIVE, + VPROC_GSK_START_INTERVAL, +} vproc_gsk_t; + +vproc_err_t vproc_swap_integer(vproc_t vp, vproc_gsk_t key, int64_t *inval, int64_t *outval); + vproc_err_t _vproc_get_last_exit_status(int *wstatus); vproc_err_t _vproc_set_global_on_demand(bool val); Modified: trunk/launchd/src/libvproc_public.h =================================================================== --- trunk/launchd/src/libvproc_public.h 2007-03-07 18:01:26 UTC (rev 23143) +++ trunk/launchd/src/libvproc_public.h 2007-03-07 22:50:49 UTC (rev 23144) @@ -27,23 +27,11 @@ #pragma GCC visibility push(default) -typedef enum { - VPROC_GSK_LAST_EXIT_STATUS = 1, - VPROC_GSK_GLOBAL_ON_DEMAND, - VPROC_GSK_MGR_UID, - VPROC_GSK_MGR_PID, - VPROC_GSK_IS_NATIVE, - VPROC_GSK_BASIC_KEEPALIVE, - VPROC_GSK_START_INTERVAL, -} vproc_gsk_t; - typedef void * vproc_err_t; typedef void * vproc_t; typedef void * vprocmgr_t; -vproc_err_t vproc_swap_integer(vproc_t vp, vproc_gsk_t key, int64_t *inval, int64_t *outval); - const char *vproc_strerror(vproc_err_t r); #pragma GCC visibility pop -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070307/0cf52c7b/attachment.html From source_changes at macosforge.org Wed Mar 7 14:53:40 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:43 2007 Subject: [launchd-changes] [23145] trunk/launchd/src/protocol_job.defs Message-ID: <20070307225340.C807A4CD25D@cvs.opensource.apple.com> Revision: 23145 http://trac.macosforge.org/projects/launchd/changeset/23145 Author: zarzycki@apple.com Date: 2007-03-07 14:53:40 -0800 (Wed, 07 Mar 2007) Log Message: ----------- Typo. Modified Paths: -------------- trunk/launchd/src/protocol_job.defs Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2007-03-07 22:50:49 UTC (rev 23144) +++ trunk/launchd/src/protocol_job.defs 2007-03-07 22:53:40 UTC (rev 23145) @@ -29,6 +29,7 @@ #include #include "launchd_mig_types.defs" import "libvproc_public.h"; +import "libvproc_private.h"; import "libvproc_internal.h"; type mach_port_move_send_array_t = array[] of mach_port_move_send_t -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070307/3d242bdb/attachment.html From source_changes at macosforge.org Thu Mar 8 15:01:26 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23146] trunk/launchd/src Message-ID: <20070308230126.66B174CEC9B@cvs.opensource.apple.com> Revision: 23146 http://trac.macosforge.org/projects/launchd/changeset/23146 Author: zarzycki@apple.com Date: 2007-03-08 15:01:26 -0800 (Thu, 08 Mar 2007) Log Message: ----------- Let's make dsym debugging work for Libsystem. Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2007-03-07 22:53:40 UTC (rev 23145) +++ trunk/launchd/src/Makefile.am 2007-03-08 23:01:26 UTC (rev 23146) @@ -29,6 +29,9 @@ cp liblaunch.a $(DESTDIR)/usr/local/lib/system cp liblaunch.a $(DESTDIR)/usr/local/lib/system/liblaunch_debug.a cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a + dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch.a.dSYM liblaunch.a + dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch_debug.a.dSYM liblaunch.a + dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch_profile.a.dSYM liblaunch_profile.a else Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-03-07 22:53:40 UTC (rev 23145) +++ trunk/launchd/src/Makefile.in 2007-03-08 23:01:26 UTC (rev 23146) @@ -1066,6 +1066,9 @@ @LIBS_ONLY_TRUE@ cp liblaunch.a $(DESTDIR)/usr/local/lib/system @LIBS_ONLY_TRUE@ cp liblaunch.a $(DESTDIR)/usr/local/lib/system/liblaunch_debug.a @LIBS_ONLY_TRUE@ cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a +@LIBS_ONLY_TRUE@ dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch.a.dSYM liblaunch.a +@LIBS_ONLY_TRUE@ dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch_debug.a.dSYM liblaunch.a +@LIBS_ONLY_TRUE@ dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch_profile.a.dSYM liblaunch_profile.a @LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h @LIBS_ONLY_FALSE@launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070308/7c6c0b0a/attachment.html From source_changes at macosforge.org Thu Mar 8 15:34:00 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23147] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070308233400.CDFC94CED8C@cvs.opensource.apple.com> Revision: 23147 http://trac.macosforge.org/projects/launchd/changeset/23147 Author: zarzycki@apple.com Date: 2007-03-08 15:34:00 -0800 (Thu, 08 Mar 2007) Log Message: ----------- Let's ditch the old reordring of the job_t list MRU hack in favor of an actual hash based lookup. 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-03-08 23:01:26 UTC (rev 23146) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-08 23:34:00 UTC (rev 23147) @@ -193,11 +193,16 @@ static void semaphoreitem_watch(job_t j, struct semaphoreitem *si); static void semaphoreitem_ignore(job_t j, struct semaphoreitem *si); +#define IS_POWER_OF_TWO(v) (!(v & (v - 1)) && v) +#define ACTIVE_JOB_HASH_SIZE 32 +#define ACTIVE_JOB_HASH(x) (IS_POWER_OF_TWO(ACTIVE_JOB_HASH_SIZE) ? (x & (ACTIVE_JOB_HASH_SIZE - 1)) : (x % ACTIVE_JOB_HASH_SIZE)) + struct jobmgr_s { kq_callback kqjobmgr_callback; SLIST_ENTRY(jobmgr_s) sle; SLIST_HEAD(, jobmgr_s) submgrs; - TAILQ_HEAD(, job_s) jobs; + SLIST_HEAD(, job_s) jobs; + SLIST_HEAD(, job_s) active_jobs[ACTIVE_JOB_HASH_SIZE]; mach_port_t jm_port; mach_port_t req_port; jobmgr_t parentmgr; @@ -230,7 +235,8 @@ struct job_s { kq_callback kqjob_callback; - TAILQ_ENTRY(job_s) sle; + SLIST_ENTRY(job_s) sle; + SLIST_ENTRY(job_s) hash_sle; SLIST_HEAD(, socketgroup) sockets; SLIST_HEAD(, calendarinterval) cal_intervals; SLIST_HEAD(, envitem) global_env; @@ -545,7 +551,7 @@ jobmgr_shutdown(jmi); } - TAILQ_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { if (!job_active(ji)) { job_remove(ji); } else if (!ji->hopefully_exits_last) { @@ -575,15 +581,15 @@ } /* We should have one job left and it should be the anonymous job */ - ji = TAILQ_FIRST(&jm->jobs); + ji = SLIST_FIRST(&jm->jobs); if (!(jobmgr_assumes(jm, ji != NULL) && jobmgr_assumes(jm, ji == jm->anonj) - && jobmgr_assumes(jm, TAILQ_NEXT(ji, sle) == NULL))) { - TAILQ_FOREACH(ji, &jm->jobs, sle) { + && jobmgr_assumes(jm, SLIST_NEXT(ji, sle) == NULL))) { + SLIST_FOREACH(ji, &jm->jobs, sle) { job_log(ji, LOG_ERR, "Still remaining at removal."); } } - while ((ji = TAILQ_FIRST(&jm->jobs))) { + while ((ji = SLIST_FIRST(&jm->jobs))) { job_remove(ji); } @@ -707,7 +713,7 @@ kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); if (job_assumes(j, j->mgr)) { - TAILQ_REMOVE(&j->mgr->jobs, j, sle); + SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); } job_log(j, LOG_DEBUG, "Removed"); @@ -998,7 +1004,7 @@ j->argv[i] = NULL; } - TAILQ_INSERT_TAIL(&jm->jobs, j, sle); + SLIST_INSERT_HEAD(&jm->jobs, j, sle); job_log(j, LOG_DEBUG, "Conceived"); @@ -1518,7 +1524,7 @@ } } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { if (strcmp(ji->label, label) == 0) { return ji; } @@ -1536,18 +1542,15 @@ if (jm->jm_port == p) { struct ldcred ldc; + pid_t hashp; runtime_get_caller_creds(&ldc); - TAILQ_FOREACH(ji, &jm->jobs, sle) { + hashp = ACTIVE_JOB_HASH(ldc.pid); + + SLIST_FOREACH(ji, &jm->active_jobs[hashp], hash_sle) { if (ji->p == ldc.pid) { - /* This is just a MRU perfomance hack */ - TAILQ_REMOVE(&jm->jobs, ji, sle); - TAILQ_INSERT_HEAD(&jm->jobs, ji, sle); return ji; - } else if (ji->p == 0) { - /* All the PIDs are at the front of the list */ - break; } } return jm->anonj; @@ -1561,7 +1564,7 @@ } } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { if (ji->j_port == p) { return ji; } @@ -1593,7 +1596,7 @@ } } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (ms->port == p) { return ji; @@ -1619,7 +1622,7 @@ job_export_all2(jmi, where); } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { launch_data_t tmp; if (jobmgr_assumes(jm, (tmp = job_export2(ji, false)) != NULL)) { @@ -1688,11 +1691,8 @@ } total_children--; + SLIST_REMOVE(&j->mgr->active_jobs[ACTIVE_JOB_HASH(j->p)], j, job_s, hash_sle); - /* Performance hack */ - TAILQ_REMOVE(&j->mgr->jobs, j, sle); - TAILQ_INSERT_TAIL(&j->mgr->jobs, j, sle); - job_assumes(j, gettimeofday(&tve, NULL) != -1); if (j->wait_reply_port) { @@ -1760,7 +1760,7 @@ jobmgr_dispatch_all(jmi); } - TAILQ_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { job_dispatch(ji, false); } } @@ -2025,11 +2025,8 @@ break; default: total_children++; + SLIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, hash_sle); - /* Performance hack */ - TAILQ_REMOVE(&j->mgr->jobs, j, sle); - TAILQ_INSERT_HEAD(&j->mgr->jobs, j, sle); - if (!j->legacy_mach_job) { job_assumes(j, close(oepair[1]) != -1); } @@ -2137,7 +2134,7 @@ jobmgr_setup_env_from_other_jobs(jm->parentmgr); } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ei, &ji->global_env, sle) { setenv(ei->key, ei->value, 1); } @@ -3303,7 +3300,7 @@ return jm; } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { if (ji->p && !ji->hopefully_exits_last) { return jm; } @@ -3311,7 +3308,7 @@ jobmgr_log(jm, LOG_DEBUG, "Asking \"hopeful\" jobs to exit."); - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { job_stop(ji); } @@ -3368,7 +3365,7 @@ return false; } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { if (ji->p) { return false; } @@ -3421,7 +3418,6 @@ return NULL; } - TAILQ_INIT(&jmr->jobs); jmr->kqjobmgr_callback = jobmgr_callback; strcpy(jmr->name, name ? name : "Under construction"); @@ -3540,7 +3536,7 @@ jobmgr_delete_anything_with_port(jmi, port); } - TAILQ_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { SLIST_FOREACH_SAFE(ms, &ji->machservices, sle, next_ms) { if (ms->port == port) { machservice_delete(ms); @@ -3565,7 +3561,7 @@ jobmgr_assumes(jm, !check_parent); } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { if (target_pid && (ji->p != target_pid)) { continue; } @@ -3728,7 +3724,7 @@ } /* We don't need the _SAFE version because we return after the job_dispatch() */ - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (ms->port != p) { continue; @@ -3947,7 +3943,7 @@ jobmgr_dispatch_all_semaphores(jmi); } - TAILQ_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { if (!SLIST_EMPTY(&ji->semaphores)) { job_dispatch(ji, false); } @@ -4313,7 +4309,7 @@ *up_cont = MACH_PORT_NULL; - TAILQ_FOREACH(ji, &root_jobmgr->jobs, sle) { + SLIST_FOREACH(ji, &root_jobmgr->jobs, sle) { if (ji->mach_uid != which_user) { continue; } @@ -4538,7 +4534,7 @@ jm = j->mgr; - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (!ms->per_pid) { cnt++; @@ -4560,7 +4556,7 @@ goto out_bad; } - TAILQ_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (!ms->per_pid) { strlcpy(service_names[cnt2], machservice_name(ms), sizeof(service_names[0])); @@ -4610,8 +4606,8 @@ } if (job_assumes(j, jmi != NULL)) { - TAILQ_REMOVE(&j->mgr->jobs, j, sle); - TAILQ_INSERT_TAIL(&jmi->jobs, j, sle); + SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); + SLIST_INSERT_HEAD(&jmi->jobs, j, sle); j->mgr = jmi; } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070308/d1d82a26/attachment.html From source_changes at macosforge.org Thu Mar 8 15:41:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23148] tags/launchd-203/ Message-ID: <20070308234129.850714CEDC8@cvs.opensource.apple.com> Revision: 23148 http://trac.macosforge.org/projects/launchd/changeset/23148 Author: zarzycki@apple.com Date: 2007-03-08 15:41:29 -0800 (Thu, 08 Mar 2007) Log Message: ----------- "Tagging launchd-203 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-203/ Copied: tags/launchd-203 (from rev 23147, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070308/d8baaac4/attachment.html From source_changes at macosforge.org Fri Mar 9 13:00:17 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23149] trunk/launchd/src/launchctl.1 Message-ID: <20070309210017.4ED8A4D1D3D@cvs.opensource.apple.com> Revision: 23149 http://trac.macosforge.org/projects/launchd/changeset/23149 Author: zarzycki@apple.com Date: 2007-03-09 13:00:17 -0800 (Fri, 09 Mar 2007) Log Message: ----------- Launchctl man pages says it takes multiple job labels, it only takes one Modified Paths: -------------- trunk/launchd/src/launchctl.1 Modified: trunk/launchd/src/launchctl.1 =================================================================== --- trunk/launchd/src/launchctl.1 2007-03-08 23:41:29 UTC (rev 23148) +++ trunk/launchd/src/launchctl.1 2007-03-09 21:00:17 UTC (rev 23149) @@ -80,12 +80,12 @@ Where to send the stderr of the program. .El .It Ar remove Ar job_label -Remove the jobs from launchd by label. +Remove the job from launchd by label. .It Ar start Ar job_label -Start the specified jobs by label. The expected use of this subcommand is for +Start the specified job by label. The expected use of this subcommand is for debugging and testing so that one can manually kick-start an on-demand server. .It Ar stop Ar job_label -Stop the specified jobs by label. If a job is on-demand, launchd may immediately +Stop the specified job by label. If a job is on-demand, launchd may immediately restart the job if launchd finds any criteria that is satisfied. Non-demand based jobs will always be restarted. Use of this subcommand is discouraged. Jobs should ideally idle timeout by themselves. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070309/befcdcc1/attachment.html From source_changes at macosforge.org Wed Mar 14 09:38:43 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23150] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070314163843.E57EB4D74A4@cvs.opensource.apple.com> Revision: 23150 http://trac.macosforge.org/projects/launchd/changeset/23150 Author: zarzycki@apple.com Date: 2007-03-14 09:38:43 -0700 (Wed, 14 Mar 2007) Log Message: ----------- Small logging changes. 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-03-09 21:00:17 UTC (rev 23149) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-14 16:38:43 UTC (rev 23150) @@ -92,7 +92,7 @@ #define LAUNCHD_MIN_JOB_RUN_TIME 10 #define LAUNCHD_ADVISABLE_IDLE_TIMEOUT 30 #define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20 -#define LAUNCHD_SIGKILL_TIMEOUT 5 +#define LAUNCHD_SIGKILL_TIMER 5 extern char **environ; @@ -1832,7 +1832,7 @@ j->sent_sigkill = true; job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, - EV_ADD, NOTE_SECONDS, LAUNCHD_SIGKILL_TIMEOUT, j) != -1); + EV_ADD, NOTE_SECONDS, LAUNCHD_SIGKILL_TIMER, j) != -1); } void @@ -1869,6 +1869,7 @@ job_assumes(j, gettimeofday(&tve, NULL) != -1); timersub(&tve, &j->sent_sigterm_time, &tvd); + tvd.tv_sec -= j->exit_timeout; job_log(j, LOG_ERR, "Did not die after sending SIGKILL %lu seconds ago...", tvd.tv_sec); } else { job_force_sampletool(j); @@ -3340,12 +3341,15 @@ for (i = 0; i < kp_cnt; i++) { pid_t p_i = kp[i].kp_proc.p_pid; pid_t pp_i = kp[i].kp_eproc.e_ppid; + const char *z = kp[i].kp_proc.p_stat == SZOMB ? "zombie " : ""; + const char *n = kp[i].kp_proc.p_comm; if (p_i == 0 || p_i == 1) { continue; } - jobmgr_log(jm, LOG_WARNING, "Stray process at shutdown: PID %u PPID %u %s", p_i, pp_i, kp[i].kp_proc.p_comm); + jobmgr_log(jm, LOG_WARNING, "Stray %sprocess at shutdown: PID %u PPID %u %s", z, p_i, pp_i, n); + /* * The kernel team requested that I not do this for Leopard. * jobmgr_assumes(jm, kill(p_i, SIGKILL) != -1); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070314/badc9220/attachment.html From source_changes at macosforge.org Fri Mar 16 07:20:56 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23151] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070316142056.F12A94D9595@cvs.opensource.apple.com> Revision: 23151 http://trac.macosforge.org/projects/launchd/changeset/23151 Author: zarzycki@apple.com Date: 2007-03-16 07:20:56 -0700 (Fri, 16 Mar 2007) Log Message: ----------- Better logging. 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-03-14 16:38:43 UTC (rev 23150) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-16 14:20:56 UTC (rev 23151) @@ -2615,6 +2615,7 @@ void semaphoreitem_callback(job_t j, struct kevent *kev) { + char invalidation_reason[100] = ""; struct semaphoreitem *si; SLIST_FOREACH(si, &j->semaphores, sle) { @@ -2637,8 +2638,28 @@ return; } - if ((NOTE_DELETE|NOTE_RENAME|NOTE_REVOKE) & kev->fflags) { - job_log(j, LOG_DEBUG, "Path invalidated: %s", si->what); + if (NOTE_DELETE & kev->fflags) { + strcat(invalidation_reason, "deleted"); + } + + if (NOTE_RENAME & kev->fflags) { + if (invalidation_reason[0]) { + strcat(invalidation_reason, "/renamed"); + } else { + strcat(invalidation_reason, "renamed"); + } + } + + if (NOTE_REVOKE & kev->fflags) { + if (invalidation_reason[0]) { + strcat(invalidation_reason, "/revoked"); + } else { + strcat(invalidation_reason, "revoked"); + } + } + + if (invalidation_reason[0]) { + job_log(j, LOG_DEBUG, "Path %s: %s", invalidation_reason, si->what); job_assumes(j, close(si->fd) == 0); si->fd = -1; /* this will get fixed in semaphoreitem_watch() */ } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070316/8ac6704a/attachment.html From source_changes at macosforge.org Fri Mar 16 07:24:14 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23152] trunk/launchd/src/launchctl.c Message-ID: <20070316142414.553604D95A1@cvs.opensource.apple.com> Revision: 23152 http://trac.macosforge.org/projects/launchd/changeset/23152 Author: zarzycki@apple.com Date: 2007-03-16 07:24:14 -0700 (Fri, 16 Mar 2007) Log Message: ----------- set BootCache timeout to 60 seconds Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-03-16 14:20:56 UTC (rev 23151) +++ trunk/launchd/src/launchctl.c 2007-03-16 14:24:14 UTC (rev 23152) @@ -1299,7 +1299,7 @@ assumes((kq = kqueue()) != -1); - EV_SET(&kev, 0, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, 90, 0); + EV_SET(&kev, 0, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, 60, 0); assumes(kevent(kq, &kev, 1, NULL, 0, NULL) != -1); EV_SET(&kev, SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, 0); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070316/0db310e4/attachment.html From source_changes at macosforge.org Mon Mar 19 10:49:44 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23153] trunk/launchd/src/liblaunch.c Message-ID: <20070319174944.4E0A44ED385@cvs.opensource.apple.com> Revision: 23153 http://trac.macosforge.org/projects/launchd/changeset/23153 Author: zarzycki@apple.com Date: 2007-03-19 10:49:43 -0700 (Mon, 19 Mar 2007) Log Message: ----------- Unaligned access can slow down the machine. Modified Paths: -------------- trunk/launchd/src/liblaunch.c Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2007-03-16 14:24:14 UTC (rev 23152) +++ trunk/launchd/src/liblaunch.c 2007-03-19 17:49:43 UTC (rev 23153) @@ -574,6 +574,8 @@ free(lh); } +#define ROUND_TO_64BIT_WORD_SIZE(x) ((x + 7) & ~7) + void launch_data_pack(launch_data_t d, void **where, size_t *len, int **fd_where, size_t *fdcnt) { @@ -613,13 +615,13 @@ o_in_w->string_len = host2big(d->string_len); *where = realloc(*where, *len + strlen(d->string) + 1); memcpy(*where + *len, d->string, strlen(d->string) + 1); - *len += strlen(d->string) + 1; + *len += ROUND_TO_64BIT_WORD_SIZE(strlen(d->string) + 1); break; case LAUNCH_DATA_OPAQUE: o_in_w->opaque_size = host2big(d->opaque_size); *where = realloc(*where, *len + d->opaque_size); memcpy(*where + *len, d->opaque, d->opaque_size); - *len += d->opaque_size; + *len += ROUND_TO_64BIT_WORD_SIZE(d->opaque_size); break; case LAUNCH_DATA_DICTIONARY: case LAUNCH_DATA_ARRAY: @@ -671,7 +673,7 @@ } r->string = conn->recvbuf + *data_offset; r->string_len = tmpcnt; - *data_offset += tmpcnt + 1; + *data_offset += ROUND_TO_64BIT_WORD_SIZE(tmpcnt + 1); break; case LAUNCH_DATA_OPAQUE: tmpcnt = big2host(r->opaque_size); @@ -681,7 +683,7 @@ } r->opaque = conn->recvbuf + *data_offset; r->opaque_size = tmpcnt; - *data_offset += tmpcnt; + *data_offset += ROUND_TO_64BIT_WORD_SIZE(tmpcnt); break; case LAUNCH_DATA_FD: if (r->fd != -1) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070319/905a31d3/attachment.html From source_changes at macosforge.org Mon Mar 19 11:26:21 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23154] trunk/launchd/src Message-ID: <20070319182621.D19EA4ED5D6@cvs.opensource.apple.com> Revision: 23154 http://trac.macosforge.org/projects/launchd/changeset/23154 Author: zarzycki@apple.com Date: 2007-03-19 11:26:21 -0700 (Mon, 19 Mar 2007) Log Message: ----------- launchd needs exec on disk mount option Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/liblaunch_public.h Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2007-03-19 17:49:43 UTC (rev 23153) +++ trunk/launchd/src/launchd.plist.5 2007-03-19 18:26:21 UTC (rev 23154) @@ -195,6 +195,8 @@ This optional key causes the job to be started if any one of the listed paths are modified. .It Sy QueueDirectories Much like the WatchPaths option, this key will watch the paths for modifications. The difference being that the job will only be started if the path is a directory and the directory is not empty. +.It Sy StartOnMount +This optional key causes the job to be started every time a filesystem is mounted. .It Sy StartInterval This optional key causes the job to be started every N seconds. If the system is asleep, the job will be started the next time the computer Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-19 17:49:43 UTC (rev 23153) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-19 18:26:21 UTC (rev 23154) @@ -222,7 +222,7 @@ static bool jobmgr_is_idle(jobmgr_t jm); static void jobmgr_log_stray_children(jobmgr_t jm); static void jobmgr_remove(jobmgr_t jm); -static void jobmgr_dispatch_all(jobmgr_t jm); +static void jobmgr_dispatch_all(jobmgr_t jm, bool newmounthack); static job_t job_mig_intran2(jobmgr_t jm, mach_port_t p); static void job_export_all2(jobmgr_t jm, launch_data_t where); static void jobmgr_callback(void *obj, struct kevent *kev); @@ -278,7 +278,7 @@ 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, removal_pending:1, - wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1; + wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1; char label[0]; }; @@ -766,7 +766,7 @@ } if (j->mgr->global_on_demand_cnt == 0) { - jobmgr_dispatch_all(j->mgr); + jobmgr_dispatch_all(j->mgr, false); } return true; @@ -1089,6 +1089,8 @@ case 'S': if (strcasecmp(key, LAUNCH_JOBKEY_SESSIONCREATE) == 0) { j->session_create = value; + } else if (strcasecmp(key, LAUNCH_JOBKEY_STARTONMOUNT) == 0) { + j->start_on_mount = value; } break; case 'l': @@ -1751,17 +1753,17 @@ } void -jobmgr_dispatch_all(jobmgr_t jm) +jobmgr_dispatch_all(jobmgr_t jm, bool newmounthack) { jobmgr_t jmi, jmn; job_t ji, jn; SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { - jobmgr_dispatch_all(jmi); + jobmgr_dispatch_all(jmi, newmounthack); } SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { - job_dispatch(ji, false); + job_dispatch(ji, newmounthack ? ji->start_on_mount : false); } } @@ -1909,6 +1911,12 @@ return (void)jobmgr_assumes(jm, false); } break; + case EVFILT_FS: + if (kev->fflags & VQ_MOUNT) { + jobmgr_dispatch_all(jm, true); + } + jobmgr_dispatch_all_semaphores(jm); + break; case EVFILT_TIMER: jobmgr_log(jm, LOG_NOTICE, "Still alive with %u children.", total_children); break; @@ -3503,6 +3511,7 @@ if (!jm) { jobmgr_assumes(jmr, kevent_mod(SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, jmr) != -1); + jobmgr_assumes(jmr, kevent_mod(0, EVFILT_FS, EV_ADD|EV_CLEAR, VQ_MOUNT|VQ_UNMOUNT|VQ_UPDATE, 0, jmr) != -1); } if (name) { Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-19 17:49:43 UTC (rev 23153) +++ trunk/launchd/src/launchd_runtime.c 2007-03-19 18:26:21 UTC (rev 23154) @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -888,6 +889,15 @@ record_caller_creds(&bufRequest->Head); + /* + * This is a total hack. We really need a bit in the kernel's proc + * struct to declare our intent. + */ + static int no_hang_fd = -1; + if (no_hang_fd == -1) { + no_hang_fd = _fd(open("/dev/autofs_nowait", 0)); + } + if (the_demux(&bufRequest->Head, &bufReply->Head) == FALSE) { /* XXX - also gross */ if (bufRequest->Head.msgh_id == MACH_NOTIFY_NO_SENDERS) { Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2007-03-19 17:49:43 UTC (rev 23153) +++ trunk/launchd/src/liblaunch_public.h 2007-03-19 18:26:21 UTC (rev 23154) @@ -81,6 +81,7 @@ #define LAUNCH_JOBKEY_HOPEFULLYEXITSLAST "HopefullyExitsLast" #define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO" #define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate" +#define LAUNCH_JOBKEY_STARTONMOUNT "StartOnMount" #define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits" #define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits" #define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070319/316beb23/attachment.html From source_changes at macosforge.org Mon Mar 19 13:51:45 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23155] trunk/launchd/src/launchctl.c Message-ID: <20070319205145.432754EDA7A@cvs.opensource.apple.com> Revision: 23155 http://trac.macosforge.org/projects/launchd/changeset/23155 Author: zarzycki@apple.com Date: 2007-03-19 13:51:44 -0700 (Mon, 19 Mar 2007) Log Message: ----------- Do the dirhelper stuff right. Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-03-19 18:26:21 UTC (rev 23154) +++ trunk/launchd/src/launchctl.c 2007-03-19 20:51:44 UTC (rev 23155) @@ -1363,7 +1363,10 @@ empty_dir(_PATH_TMP, NULL); remove(_PATH_NOLOGIN); - // XXX --> RMRF_ITEMS="/var/tmp/folders.* + if (path_check("/usr/libexec/dirhelper")) { + const char *dirhelper_tool[] = { "/usr/libexec/dirhelper", "-machineBoot", NULL }; + assumes(fwexec(dirhelper_tool, true) != -1); + } // 775 root:daemon /var/run/StartupItems -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070319/c1cf10a1/attachment.html From source_changes at macosforge.org Mon Mar 19 13:52:05 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23156] tags/launchd-204/ Message-ID: <20070319205205.F2AA84EDA80@cvs.opensource.apple.com> Revision: 23156 http://trac.macosforge.org/projects/launchd/changeset/23156 Author: zarzycki@apple.com Date: 2007-03-19 13:52:05 -0700 (Mon, 19 Mar 2007) Log Message: ----------- "Tagging launchd-204 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-204/ Copied: tags/launchd-204 (from rev 23155, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070319/3cbc5716/attachment.html From source_changes at macosforge.org Mon Mar 19 18:28:19 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23157] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070320012819.3138B4EE3A3@cvs.opensource.apple.com> Revision: 23157 http://trac.macosforge.org/projects/launchd/changeset/23157 Author: zarzycki@apple.com Date: 2007-03-19 18:28:18 -0700 (Mon, 19 Mar 2007) Log Message: ----------- We never did anything interesting with struct rusage accumulation. Let's disable the code for now and save some memory. 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-03-19 20:52:05 UTC (rev 23156) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-20 01:28:18 UTC (rev 23157) @@ -233,6 +233,8 @@ /* static void jobmgr_log_error(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); */ static void jobmgr_log_bug(jobmgr_t jm, const char *rcs_rev, const char *path, unsigned int line, const char *test); +#define DO_RUSAGE_SUMATION 0 + struct job_s { kq_callback kqjob_callback; SLIST_ENTRY(job_s) sle; @@ -244,7 +246,9 @@ SLIST_HEAD(, limititem) limits; SLIST_HEAD(, machservice) machservices; SLIST_HEAD(, semaphoreitem) semaphores; +#if DO_RUSAGE_SUMATION struct rusage ru; +#endif binpref_t j_binpref; size_t j_binpref_cnt; mach_port_t j_port; @@ -1713,6 +1717,7 @@ job_log(j, LOG_INFO, "Exited %f seconds after SIGTERM was sent", delta); } +#if DO_RUSAGE_SUMATION timeradd(&ru.ru_utime, &j->ru.ru_utime, &j->ru.ru_utime); timeradd(&ru.ru_stime, &j->ru.ru_stime, &j->ru.ru_stime); j->ru.ru_maxrss += ru.ru_maxrss; @@ -1729,6 +1734,7 @@ j->ru.ru_nsignals += ru.ru_nsignals; j->ru.ru_nvcsw += ru.ru_nvcsw; j->ru.ru_nivcsw += ru.ru_nivcsw; +#endif if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { job_log(j, LOG_WARNING, "exited with exit code: %d", WEXITSTATUS(status)); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070319/29f6f00d/attachment.html From source_changes at macosforge.org Tue Mar 20 09:07:48 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23158] trunk/launchd/src Message-ID: <20070320160748.09A5C4EF8BD@cvs.opensource.apple.com> Revision: 23158 http://trac.macosforge.org/projects/launchd/changeset/23158 Author: zarzycki@apple.com Date: 2007-03-20 09:07:47 -0700 (Tue, 20 Mar 2007) Log Message: ----------- Regression: launch_data_dict_lookup() no longer returns NULL outside of launchd Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/launchd_unix_ipc.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-20 01:28:18 UTC (rev 23157) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-20 16:07:47 UTC (rev 23158) @@ -315,7 +315,6 @@ static void job_callback_proc(job_t j, int flags, int fflags); static void job_callback_timer(job_t j, void *ident); static void job_callback_read(job_t j, int ident); -static launch_data_t job_export2(job_t j, bool subjobs); static job_t job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv); static job_t job_new_spawn(job_t j, const char *label, const char *path, const char *workingdir, const char *const *argv, const char *const *env, mode_t *u_mask, bool w4d); static job_t job_new_via_mach_init(job_t j, const char *cmd, uid_t uid, bool ond); @@ -431,12 +430,6 @@ launch_data_t job_export(job_t j) { - return job_export2(j, true); -} - -launch_data_t -job_export2(job_t j, bool subjobs) -{ launch_data_t tmp, tmp2, tmp3, r = launch_data_alloc(LAUNCH_DATA_DICTIONARY); if (r == NULL) { @@ -1631,7 +1624,7 @@ SLIST_FOREACH(ji, &jm->jobs, sle) { launch_data_t tmp; - if (jobmgr_assumes(jm, (tmp = job_export2(ji, false)) != NULL)) { + if (jobmgr_assumes(jm, (tmp = job_export(ji)) != NULL)) { launch_data_dict_insert(where, tmp, ji->label); } } @@ -3808,6 +3801,12 @@ return NULL; } +bool +job_is_anonymous(job_t j) +{ + return j->anonymous; +} + pid_t job_get_pid(job_t j) { Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-03-20 01:28:18 UTC (rev 23157) +++ trunk/launchd/src/launchd_core_logic.h 2007-03-20 16:07:47 UTC (rev 23158) @@ -41,6 +41,7 @@ job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */ bool job_active(job_t j); +bool job_is_anonymous(job_t j); launch_data_t job_export(job_t j); void job_stop(job_t j); void job_checkin(job_t j); Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2007-03-20 01:28:18 UTC (rev 23157) +++ trunk/launchd/src/launchd_unix_ipc.c 2007-03-20 16:07:47 UTC (rev 23158) @@ -344,7 +344,7 @@ if (data == NULL) { if (!strcmp(cmd, LAUNCH_KEY_CHECKIN)) { - if (rmc->c->j) { + if (!job_is_anonymous(rmc->c->j)) { resp = job_export(rmc->c->j); job_checkin(rmc->c->j); } else { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070320/eb949890/attachment.html From source_changes at macosforge.org Tue Mar 20 09:36:51 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23159] trunk/launchd/src/launchctl.c Message-ID: <20070320163651.6DDCB4EF975@cvs.opensource.apple.com> Revision: 23159 http://trac.macosforge.org/projects/launchd/changeset/23159 Author: zarzycki@apple.com Date: 2007-03-20 09:36:51 -0700 (Tue, 20 Mar 2007) Log Message: ----------- 9A392: Bug reported by launchctl when Safe booted Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-03-20 16:07:47 UTC (rev 23158) +++ trunk/launchd/src/launchctl.c 2007-03-20 16:36:51 UTC (rev 23159) @@ -1411,6 +1411,10 @@ { const char *bcc_tool[] = { "BootCacheControl", "-f", "/var/db/BootCache.playlist", NULL, NULL }; + if (is_safeboot()) { + return; + } + switch (what) { case BOOTCACHE_START: bcc_tool[3] = "start"; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070320/8ad0038b/attachment.html From source_changes at macosforge.org Tue Mar 20 09:48:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23160] trunk/launchd/src/libvproc_private.h Message-ID: <20070320164849.3FA5A4EF9AF@cvs.opensource.apple.com> Revision: 23160 http://trac.macosforge.org/projects/launchd/changeset/23160 Author: zarzycki@apple.com Date: 2007-03-20 09:48:48 -0700 (Tue, 20 Mar 2007) Log Message: ----------- add session type constants to headers Modified Paths: -------------- trunk/launchd/src/libvproc_private.h Modified: trunk/launchd/src/libvproc_private.h =================================================================== --- trunk/launchd/src/libvproc_private.h 2007-03-20 16:36:51 UTC (rev 23159) +++ trunk/launchd/src/libvproc_private.h 2007-03-20 16:48:48 UTC (rev 23160) @@ -47,6 +47,12 @@ void _vproc_log(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3))); void _vproc_log_error(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3))); +#define VPROCMGR_SESSION_LOGINWINDOW "LoginWindow" +#define VPROCMGR_SESSION_BACKGROUND "Background" +#define VPROCMGR_SESSION_AQUA "Aqua" +#define VPROCMGR_SESSION_STANDARDIO "StandardIO" +#define VPROCMGR_SESSION_SYSTEM "System" + vproc_err_t _vprocmgr_move_subset_to_user(uid_t target_user, char *session_type); #pragma GCC visibility pop -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070320/cc8b6d6c/attachment.html From source_changes at macosforge.org Tue Mar 20 16:59:20 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23161] trunk/launchd/src Message-ID: <20070320235920.88B954F06E3@cvs.opensource.apple.com> Revision: 23161 http://trac.macosforge.org/projects/launchd/changeset/23161 Author: zarzycki@apple.com Date: 2007-03-20 16:59:19 -0700 (Tue, 20 Mar 2007) Log Message: ----------- Switch to bootstrap_register2 prevents using accessibility with test framework builds Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/launchd_mig_types.defs trunk/launchd/src/launchd_unix_ipc.c trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h trunk/launchd/src/protocol_job.defs Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-20 16:48:48 UTC (rev 23160) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-20 23:59:19 UTC (rev 23161) @@ -206,7 +206,6 @@ mach_port_t jm_port; mach_port_t req_port; jobmgr_t parentmgr; - job_t anonj; int reboot_flags; unsigned int global_on_demand_cnt; unsigned int sent_stop_to_hopeful_jobs:1, shutting_down:1; @@ -219,6 +218,7 @@ static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name); static jobmgr_t jobmgr_parent(jobmgr_t jm); static jobmgr_t jobmgr_do_garbage_collection(jobmgr_t jm); +static void jobmgr_reap_bulk(jobmgr_t jm, struct kevent *kev); static bool jobmgr_is_idle(jobmgr_t jm); static void jobmgr_log_stray_children(jobmgr_t jm); static void jobmgr_remove(jobmgr_t jm); @@ -315,6 +315,7 @@ static void job_callback_proc(job_t j, int flags, int fflags); static void job_callback_timer(job_t j, void *ident); static void job_callback_read(job_t j, int ident); +static job_t job_new_anonymous(jobmgr_t jm, pid_t anonpid); static job_t job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv); static job_t job_new_spawn(job_t j, const char *label, const char *path, const char *workingdir, const char *const *argv, const char *const *env, mode_t *u_mask, bool w4d); static job_t job_new_via_mach_init(job_t j, const char *cmd, uid_t uid, bool ond); @@ -417,14 +418,17 @@ void job_stop(job_t j) { - if (j->p) { - job_assumes(j, kill(j->p, SIGTERM) != -1); - job_assumes(j, gettimeofday(&j->sent_sigterm_time, NULL) != -1); - if (j->exit_timeout) { - job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, - EV_ADD|EV_ONESHOT, NOTE_SECONDS, j->exit_timeout, j) != -1); - } + if (!j->p || j->anonymous) { + return; } + + job_assumes(j, kill(j->p, SIGTERM) != -1); + job_assumes(j, gettimeofday(&j->sent_sigterm_time, NULL) != -1); + + if (j->exit_timeout) { + job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, + EV_ADD|EV_ONESHOT, NOTE_SECONDS, j->exit_timeout, j) != -1); + } } launch_data_t @@ -577,16 +581,9 @@ } } - /* We should have one job left and it should be the anonymous job */ - ji = SLIST_FIRST(&jm->jobs); - if (!(jobmgr_assumes(jm, ji != NULL) && jobmgr_assumes(jm, ji == jm->anonj) - && jobmgr_assumes(jm, SLIST_NEXT(ji, sle) == NULL))) { - SLIST_FOREACH(ji, &jm->jobs, sle) { - job_log(ji, LOG_ERR, "Still remaining at removal."); - } - } - while ((ji = SLIST_FIRST(&jm->jobs))) { + /* We should only have anonymous jobs left */ + job_assumes(ji, ji->anonymous); job_remove(ji); } @@ -624,7 +621,7 @@ struct machservice *ms; struct semaphoreitem *si; - if (j->p) { + if (j->p && !j->anonymous) { job_log(j, LOG_DEBUG, "Removal pended until the job exits."); if (!j->removal_pending) { @@ -917,19 +914,28 @@ } job_t -jobmgr_get_anonymous(jobmgr_t jm) +job_new_anonymous(jobmgr_t jm, pid_t anonpid) { - char newlabel[1000], *procname = "unknown"; - job_t jr; + int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, anonpid }; + char newlabel[1000]; + struct kinfo_proc kp; + size_t len = sizeof(kp); + job_t jr = NULL; - if (jm->anonj) { - return jm->anonj; + if (!jobmgr_assumes(jm, sysctl(mib, 4, &kp, &len, NULL, 0) != -1)) { + return NULL; } - snprintf(newlabel, sizeof(newlabel), "%u.anonymous", MACH_PORT_INDEX(jm->jm_port)); + snprintf(newlabel, sizeof(newlabel), "anonymous-%u.%s", anonpid, kp.kp_proc.p_comm); - if ((jr = job_new(jm, newlabel, procname, NULL))) { + if (jobmgr_assumes(jm, (jr = job_new(jm, newlabel, kp.kp_proc.p_comm, NULL)) != NULL)) { + total_children++; jr->anonymous = true; + jr->p = anonpid; + /* anonymous process reaping is messy */ + SLIST_INSERT_HEAD(&jm->active_jobs[ACTIVE_JOB_HASH(jr->p)], jr, hash_sle); + job_assumes(jr, kevent_mod(jr->p, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, root_jobmgr) != -1); + job_log(jr, LOG_DEBUG, "Created anonymously."); } return jr; @@ -1552,7 +1558,7 @@ return ji; } } - return jm->anonj; + return job_new_anonymous(jm, ldc.pid); } SLIST_FOREACH(jmi, &jm->submgrs, sle) { @@ -1577,8 +1583,20 @@ { job_t jr = job_mig_intran2(root_jobmgr, p); - launchd_assumes(jr != NULL); + if (!jobmgr_assumes(root_jobmgr, jr != NULL)) { + int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, 0 }; + struct kinfo_proc kp; + struct ldcred ldc; + size_t len = sizeof(kp); + runtime_get_caller_creds(&ldc); + mib[3] = ldc.pid; + + if (jobmgr_assumes(root_jobmgr, sysctl(mib, 4, &kp, &len, NULL, 0) != -1)) { + jobmgr_log(root_jobmgr, LOG_ERR, "%s() was confused by PID %u: %s", __func__, ldc.pid, kp.kp_proc.p_comm); + } + } + return jr; } @@ -1647,7 +1665,7 @@ { struct timeval tve, tvd; struct rusage ru; - int status; + int status = 0; job_log(j, LOG_DEBUG, "Reaping"); @@ -1672,7 +1690,7 @@ j->forkfd = 0; } - if (!job_assumes(j, wait4(j->p, &status, 0, &ru) != -1)) { + if (!j->anonymous && !job_assumes(j, wait4(j->p, &status, 0, &ru) != -1)) { /* * wait4() then kill() is still racy. * Then again, we never should have got here in the first place... @@ -1681,7 +1699,6 @@ job_log(j, LOG_DEBUG, "Working around 5020256"); } - status = 0; memset(&ru, 0, sizeof(ru)); } @@ -1828,6 +1845,10 @@ void job_kill(job_t j) { + if (!j->p || j->anonymous) { + return; + } + job_assumes(j, kill(j->p, SIGKILL) != -1); j->sent_sigkill = true; @@ -1851,10 +1872,11 @@ job_assumes(j, (flags & EV_ONESHOT)); job_assumes(j, (flags & EV_EOF)); job_reap(j); - job_dispatch(j, false); - if (launchd_assumes(root_jobmgr != NULL)) { - root_jobmgr = jobmgr_do_garbage_collection(root_jobmgr); + if (j->anonymous) { + job_remove(j); + } else { + job_dispatch(j, false); } } } @@ -1897,11 +1919,39 @@ } void +jobmgr_reap_bulk(jobmgr_t jm, struct kevent *kev) +{ + jobmgr_t jmi; + job_t ji; + + SLIST_FOREACH(jmi, &jm->submgrs, sle) { + jobmgr_reap_bulk(jmi, kev); + } + + SLIST_FOREACH(ji, &jm->active_jobs[ACTIVE_JOB_HASH(kev->ident)], hash_sle) { + if (ji->p != (pid_t)kev->ident) { + continue; + } + + kev->udata = ji; + job_callback(ji, kev); + + break; + } +} + +void jobmgr_callback(void *obj, struct kevent *kev) { jobmgr_t jm = obj; switch (kev->filter) { + case EVFILT_PROC: + jobmgr_reap_bulk(jm, kev); + if (launchd_assumes(root_jobmgr != NULL)) { + root_jobmgr = jobmgr_do_garbage_collection(root_jobmgr); + } + break; case EVFILT_SIGNAL: switch (kev->ident) { case SIGTERM: @@ -3398,7 +3448,7 @@ } SLIST_FOREACH(ji, &jm->jobs, sle) { - if (ji->p) { + if (ji->p && !ji->anonymous) { return false; } } @@ -3506,8 +3556,6 @@ mxmsgsz = job_mig_protocol_vproc_subsystem.maxsize; } - jobmgr_assumes(jmr, (jmr->anonj = jobmgr_get_anonymous(jmr)) != NULL); - if (!jm) { jobmgr_assumes(jmr, kevent_mod(SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, jmr) != -1); jobmgr_assumes(jmr, kevent_mod(0, EVFILT_FS, EV_ADD|EV_CLEAR, VQ_MOUNT|VQ_UNMOUNT|VQ_UPDATE, 0, jmr) != -1); @@ -4654,18 +4702,22 @@ kern_return_t job_mig_move_subset(job_t j, mach_port_t target_subset, name_t session_type) { - mach_msg_type_number_t l2l_i, l2l_name_cnt = 0, l2l_port_cnt = 0; + mach_msg_type_number_t l2l_i, l2l_name_cnt = 0, l2l_port_cnt = 0, l2l_pid_cnt = 0; name_array_t l2l_names = NULL; + pid_array_t l2l_pids = NULL; mach_port_array_t l2l_ports = NULL; mach_port_t reqport, rcvright; kern_return_t kr; jobmgr_t jmr; + job_t j2; if (getuid() == 0) { const char *bootstrap_tool[] = { "/bin/launchctl", "bootstrap", "-S", session_type, NULL }; job_t bootstrapper; - j = job_mig_intran2(root_jobmgr, target_subset); + job_assumes(j, (j2 = job_mig_intran2(root_jobmgr, target_subset)) != NULL); + j = j2; + jobmgr_log(j->mgr, LOG_DEBUG, "Renaming to: %s", session_type); strcpy(j->mgr->name, session_type); job_assumes(j, launchd_mport_deallocate(target_subset) == KERN_SUCCESS); @@ -4677,7 +4729,9 @@ } kr = _vproc_grab_subset(target_subset, &reqport, - &rcvright, &l2l_names, &l2l_name_cnt, &l2l_ports, &l2l_port_cnt); + &rcvright, &l2l_names, &l2l_name_cnt, + &l2l_pids, &l2l_pid_cnt, + &l2l_ports, &l2l_port_cnt); if (job_assumes(j, kr == 0)) { job_assumes(j, launchd_mport_deallocate(target_subset) == KERN_SUCCESS); @@ -4686,6 +4740,7 @@ } launchd_assert(l2l_name_cnt == l2l_port_cnt); + launchd_assert(l2l_name_cnt == l2l_pid_cnt); if ((jmr = jobmgr_new(j->mgr, reqport, rcvright, false, session_type)) == NULL) { kr = BOOTSTRAP_NO_MEMORY; @@ -4694,8 +4749,20 @@ for (l2l_i = 0; l2l_i < l2l_name_cnt; l2l_i++) { struct machservice *ms; + job_t j_for_service; - if ((ms = machservice_new(jmr->anonj, l2l_names[l2l_i], &l2l_ports[l2l_i], false))) { + SLIST_FOREACH(j_for_service, &jmr->jobs, sle) { + if (j_for_service->p == l2l_pids[l2l_i]) { + break; + } + } + + if (!j_for_service) { + j_for_service = job_new_anonymous(jmr, l2l_pids[l2l_i]); + jobmgr_assumes(jmr, j_for_service != NULL); + } + + if ((ms = machservice_new(j_for_service, l2l_names[l2l_i], &l2l_ports[l2l_i], false))) { machservice_request_notifications(ms); } } @@ -4709,6 +4776,9 @@ if (l2l_ports) { mig_deallocate((vm_address_t)l2l_ports, l2l_port_cnt * sizeof(l2l_ports[0])); } + if (l2l_pids) { + mig_deallocate((vm_address_t)l2l_pids, l2l_pid_cnt * sizeof(l2l_pids[0])); + } return kr; } @@ -4716,13 +4786,16 @@ kern_return_t job_mig_take_subset(job_t j, mach_port_t *reqport, mach_port_t *rcvright, name_array_t *servicenamesp, unsigned int *servicenames_cnt, + pid_array_t *pidsp, unsigned int *pids_cnt, mach_port_array_t *portsp, unsigned int *ports_cnt) { name_array_t service_names = NULL; mach_port_array_t ports = NULL; + pid_array_t pids = NULL; unsigned int cnt = 0, cnt2 = 0; struct machservice *ms; jobmgr_t jm; + job_t ji; if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; @@ -4743,8 +4816,13 @@ job_log(j, LOG_DEBUG, "Transferring sub-bootstrap to the per session launchd."); - SLIST_FOREACH(ms, &j->machservices, sle) { - cnt++; + SLIST_FOREACH(ji, &j->mgr->jobs, sle) { + if (!ji->anonymous) { + continue; + } + SLIST_FOREACH(ms, &ji->machservices, sle) { + cnt++; + } } mig_allocate((vm_address_t *)&service_names, cnt * sizeof(service_names[0])); @@ -4757,19 +4835,31 @@ goto out_bad; } - SLIST_FOREACH(ms, &j->machservices, sle) { - strlcpy(service_names[cnt2], machservice_name(ms), sizeof(service_names[0])); - ports[cnt2] = machservice_port(ms); - /* Increment the send right by one so we can shutdown the jobmgr cleanly */ - jobmgr_assumes(jm, (errno = mach_port_mod_refs(mach_task_self(), ports[cnt2], MACH_PORT_RIGHT_SEND, 1)) == 0); - cnt2++; + mig_allocate((vm_address_t *)&pids, cnt * sizeof(pids[0])); + if (!launchd_assumes(pids != NULL)) { + goto out_bad; } + SLIST_FOREACH(ji, &j->mgr->jobs, sle) { + if (!ji->anonymous) { + continue; + } + SLIST_FOREACH(ms, &ji->machservices, sle) { + strlcpy(service_names[cnt2], machservice_name(ms), sizeof(service_names[0])); + ports[cnt2] = machservice_port(ms); + pids[cnt2] = ms->job->p; + /* Increment the send right by one so we can shutdown the jobmgr cleanly */ + jobmgr_assumes(jm, (errno = mach_port_mod_refs(mach_task_self(), ports[cnt2], MACH_PORT_RIGHT_SEND, 1)) == 0); + cnt2++; + } + } + launchd_assumes(cnt == cnt2); *servicenamesp = service_names; *portsp = ports; - *servicenames_cnt = *ports_cnt = cnt; + *pidsp = pids; + *servicenames_cnt = *ports_cnt = *pids_cnt = cnt; *reqport = jm->req_port; *rcvright = jm->jm_port; @@ -4785,6 +4875,9 @@ if (service_names) { mig_deallocate((vm_address_t)service_names, cnt * sizeof(service_names[0])); } + if (pids) { + mig_deallocate((vm_address_t)pids, cnt * sizeof(pids[0])); + } if (ports) { mig_deallocate((vm_address_t)ports, cnt * sizeof(ports[0])); } Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-03-20 16:48:48 UTC (rev 23160) +++ trunk/launchd/src/launchd_core_logic.h 2007-03-20 23:59:19 UTC (rev 23161) @@ -31,7 +31,6 @@ void jobmgr_init(bool); jobmgr_t jobmgr_shutdown(jobmgr_t jm); void jobmgr_dispatch_all_semaphores(jobmgr_t jm); -job_t jobmgr_get_anonymous(jobmgr_t jm); job_t jobmgr_find(jobmgr_t jm, const char *label); jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port); bool jobmgr_ack_port_destruction(jobmgr_t jm, mach_port_t p); Modified: trunk/launchd/src/launchd_mig_types.defs =================================================================== --- trunk/launchd/src/launchd_mig_types.defs 2007-03-20 16:48:48 UTC (rev 23160) +++ trunk/launchd/src/launchd_mig_types.defs 2007-03-20 23:59:19 UTC (rev 23161) @@ -24,6 +24,7 @@ */ type pid_t = integer_t; +type pid_array_t = ^array [] of pid_t; type uid_t = integer_t; type gid_t = integer_t; type vproc_gsk_t = integer_t; Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2007-03-20 16:48:48 UTC (rev 23160) +++ trunk/launchd/src/launchd_unix_ipc.c 2007-03-20 23:59:19 UTC (rev 23161) @@ -184,7 +184,7 @@ c->kqconn_callback = ipc_callback; c->conn = launchd_fdopen(fd); - c->j = j ? j : jobmgr_get_anonymous(root_jobmgr); + c->j = j; SLIST_INSERT_HEAD(&connections, c, sle); kevent_mod(fd, EVFILT_READ, EV_ADD, 0, 0, &c->kqconn_callback); } @@ -340,11 +340,11 @@ return; } - job_log(rmc->c->j, LOG_DEBUG, "Unix IPC request: %s", cmd); + //job_log(rmc->c->j, LOG_DEBUG, "Unix IPC request: %s", cmd); if (data == NULL) { if (!strcmp(cmd, LAUNCH_KEY_CHECKIN)) { - if (!job_is_anonymous(rmc->c->j)) { + if (rmc->c->j) { resp = job_export(rmc->c->j); job_checkin(rmc->c->j); } else { Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-03-20 16:48:48 UTC (rev 23160) +++ trunk/launchd/src/libvproc.c 2007-03-20 23:59:19 UTC (rev 23161) @@ -41,9 +41,10 @@ kern_return_t _vproc_grab_subset(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + pid_array_t *pids, mach_msg_type_number_t *pidCnt, mach_port_array_t *ports, mach_msg_type_number_t *portCnt) { - return vproc_mig_take_subset(bp, reqport, rcvright, service_names, service_namesCnt, ports, portCnt); + return vproc_mig_take_subset(bp, reqport, rcvright, service_names, service_namesCnt, pids, pidCnt, ports, portCnt); } vproc_err_t Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2007-03-20 16:48:48 UTC (rev 23160) +++ trunk/launchd/src/libvproc_internal.h 2007-03-20 23:59:19 UTC (rev 23161) @@ -26,6 +26,7 @@ typedef char * _internal_string_t; typedef char * logmsg_t; +typedef pid_t * pid_array_t; typedef mach_port_t vproc_mig_t; typedef integer_t binpref_t[8]; @@ -46,6 +47,7 @@ kern_return_t _vproc_grab_subset(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + pid_array_t *pids, mach_msg_type_number_t *pidCnt, mach_port_array_t *ports, mach_msg_type_number_t *portCnt); kern_return_t _vprocmgr_getsocket(name_t); Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2007-03-20 16:48:48 UTC (rev 23160) +++ trunk/launchd/src/protocol_job.defs 2007-03-20 23:59:19 UTC (rev 23161) @@ -96,6 +96,7 @@ out __bs_reqport : mach_port_move_send_t; out __bs_rcvright : mach_port_move_receive_t; out __service_names : name_array_t, dealloc; + out __service_pids : pid_array_t, dealloc; out __service_ports : mach_port_move_send_array_t, dealloc); routine getsocket( -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070320/b4be4de1/attachment.html From source_changes at macosforge.org Tue Mar 20 17:42:11 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23162] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070321004211.8A9414F07E6@cvs.opensource.apple.com> Revision: 23162 http://trac.macosforge.org/projects/launchd/changeset/23162 Author: zarzycki@apple.com Date: 2007-03-20 17:42:11 -0700 (Tue, 20 Mar 2007) Log Message: ----------- Typo. 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-03-20 23:59:19 UTC (rev 23161) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-21 00:42:11 UTC (rev 23162) @@ -233,7 +233,7 @@ /* static void jobmgr_log_error(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); */ static void jobmgr_log_bug(jobmgr_t jm, const char *rcs_rev, const char *path, unsigned int line, const char *test); -#define DO_RUSAGE_SUMATION 0 +#define DO_RUSAGE_SUMMATION 0 struct job_s { kq_callback kqjob_callback; @@ -246,7 +246,7 @@ SLIST_HEAD(, limititem) limits; SLIST_HEAD(, machservice) machservices; SLIST_HEAD(, semaphoreitem) semaphores; -#if DO_RUSAGE_SUMATION +#if DO_RUSAGE_SUMMATION struct rusage ru; #endif binpref_t j_binpref; @@ -1727,7 +1727,7 @@ job_log(j, LOG_INFO, "Exited %f seconds after SIGTERM was sent", delta); } -#if DO_RUSAGE_SUMATION +#if DO_RUSAGE_SUMMATION timeradd(&ru.ru_utime, &j->ru.ru_utime, &j->ru.ru_utime); timeradd(&ru.ru_stime, &j->ru.ru_stime, &j->ru.ru_stime); j->ru.ru_maxrss += ru.ru_maxrss; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070320/433f8589/attachment.html From source_changes at macosforge.org Tue Mar 20 17:54:01 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23163] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070321005401.BC9434F0829@cvs.opensource.apple.com> Revision: 23163 http://trac.macosforge.org/projects/launchd/changeset/23163 Author: zarzycki@apple.com Date: 2007-03-20 17:54:01 -0700 (Tue, 20 Mar 2007) Log Message: ----------- Job manager GC is painful right now. 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-03-21 00:42:11 UTC (rev 23162) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-21 00:54:01 UTC (rev 23163) @@ -2095,7 +2095,7 @@ job_assumes(j, 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, j) == -1) { + 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()"); job_reap(j); } else { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070320/6ba03987/attachment.html From source_changes at macosforge.org Wed Mar 21 11:35:07 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23164] trunk/launchd/src Message-ID: <20070321183507.63F524F135B@cvs.opensource.apple.com> Revision: 23164 http://trac.macosforge.org/projects/launchd/changeset/23164 Author: zarzycki@apple.com Date: 2007-03-21 11:35:06 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Hashing is good for the soul. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/launchd_unix_ipc.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-21 00:54:01 UTC (rev 23163) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-21 18:35:06 UTC (rev 23164) @@ -235,10 +235,13 @@ #define DO_RUSAGE_SUMMATION 0 +#define AUTO_PICK_LEGACY_MACH_LABEL (const char *)(~0) + struct job_s { kq_callback kqjob_callback; SLIST_ENTRY(job_s) sle; - SLIST_ENTRY(job_s) hash_sle; + SLIST_ENTRY(job_s) pid_hash_sle; + SLIST_ENTRY(job_s) label_hash_sle; SLIST_HEAD(, socketgroup) sockets; SLIST_HEAD(, calendarinterval) cal_intervals; SLIST_HEAD(, envitem) global_env; @@ -283,9 +286,15 @@ 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, removal_pending:1, wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1; - char label[0]; + const char label[0]; }; +#define LABEL_HASH_SIZE 53 + +SLIST_HEAD(, job_s) label_hash[LABEL_HASH_SIZE]; +static size_t hash_label(const char *label); + + #define job_assumes(j, e) \ (__builtin_expect(!(e), 0) ? job_log_bug(j, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) @@ -706,9 +715,8 @@ kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); - if (job_assumes(j, j->mgr)) { - SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); - } + SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); + SLIST_REMOVE(&label_hash[hash_label(j->label)], j, job_s, label_hash_sle); job_log(j, LOG_DEBUG, "Removed"); @@ -802,17 +810,13 @@ { const char **argv = (const char **)mach_cmd2argv(cmd); job_t jr = NULL; - char buf[1000]; if (!job_assumes(j, argv != NULL)) { goto out_bad; } - /* preflight the string so we know how big it is */ - snprintf(buf, sizeof(buf), "%s.%s", sizeof(void *) == 8 ? "0xdeadbeeffeedface" : "0xbabecafe", basename((char *)argv[0])); + jr = job_new(j->mgr, AUTO_PICK_LEGACY_MACH_LABEL, NULL, argv); - jr = job_new(j->mgr, buf, NULL, argv); - free(argv); /* jobs can easily be denied creation during shutdown */ @@ -820,8 +824,6 @@ goto out_bad; } - snprintf(jr->label, strlen(jr->label) + 1, "%p.%s", jr, basename(jr->argv[0])); - jr->mach_uid = uid; jr->ondemand = ond; jr->legacy_mach_job = true; @@ -861,7 +863,7 @@ job_t jr; size_t i; - if ((jr = jobmgr_find(root_jobmgr, label)) != NULL) { + if ((jr = job_find(label)) != NULL) { errno = EEXIST; return NULL; } @@ -933,7 +935,7 @@ jr->anonymous = true; jr->p = anonpid; /* anonymous process reaping is messy */ - SLIST_INSERT_HEAD(&jm->active_jobs[ACTIVE_JOB_HASH(jr->p)], jr, hash_sle); + SLIST_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_EXIT, 0, root_jobmgr) != -1); job_log(jr, LOG_DEBUG, "Created anonymously."); } @@ -945,6 +947,8 @@ job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv) { const char *const *argv_tmp = argv; + char auto_label[1000]; + char *bn = NULL; char *co; int i, cc = 0; job_t j; @@ -961,13 +965,23 @@ return NULL; } + if (label == AUTO_PICK_LEGACY_MACH_LABEL) { + bn = basename((char *)argv[0]); + snprintf(auto_label, sizeof(auto_label), "%s.%s", sizeof(void *) == 8 ? "0xdeadbeeffeedface" : "0xbabecafe", bn); + label = auto_label; + } + j = calloc(1, sizeof(struct job_s) + strlen(label) + 1); if (!jobmgr_assumes(jm, j != NULL)) { return NULL; } - strcpy(j->label, label); + if (label == auto_label) { + snprintf((char *)j->label, strlen(label) + 1, "%p.%s", j, bn); + } else { + strcpy((char *)j->label, label); + } j->kqjob_callback = job_callback; j->mgr = jm; j->min_run_time = LAUNCHD_MIN_JOB_RUN_TIME; @@ -1008,6 +1022,7 @@ } SLIST_INSERT_HEAD(&jm->jobs, j, sle); + SLIST_INSERT_HEAD(&label_hash[hash_label(j->label)], j, label_hash_sle); job_log(j, LOG_DEBUG, "Conceived"); @@ -1499,7 +1514,7 @@ argv[i] = NULL; } - if ((j = jobmgr_find(root_jobmgr, label)) != NULL) { + if ((j = job_find(label)) != NULL) { errno = EEXIST; return NULL; } else if (label[0] == '\0' || (strncasecmp(label, "", strlen("com.apple.launchd")) == 0) || @@ -1518,18 +1533,11 @@ } job_t -jobmgr_find(jobmgr_t jm, const char *label) +job_find(const char *label) { - jobmgr_t jmi; job_t ji; - SLIST_FOREACH(jmi, &jm->submgrs, sle) { - if ((ji = jobmgr_find(jmi, label))) { - return ji; - } - } - - SLIST_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH(ji, &label_hash[hash_label(label)], label_hash_sle) { if (strcmp(ji->label, label) == 0) { return ji; } @@ -1553,7 +1561,7 @@ hashp = ACTIVE_JOB_HASH(ldc.pid); - SLIST_FOREACH(ji, &jm->active_jobs[hashp], hash_sle) { + SLIST_FOREACH(ji, &jm->active_jobs[hashp], pid_hash_sle) { if (ji->p == ldc.pid) { return ji; } @@ -1707,7 +1715,7 @@ } total_children--; - SLIST_REMOVE(&j->mgr->active_jobs[ACTIVE_JOB_HASH(j->p)], j, job_s, hash_sle); + SLIST_REMOVE(&j->mgr->active_jobs[ACTIVE_JOB_HASH(j->p)], j, job_s, pid_hash_sle); job_assumes(j, gettimeofday(&tve, NULL) != -1); @@ -1928,7 +1936,7 @@ jobmgr_reap_bulk(jmi, kev); } - SLIST_FOREACH(ji, &jm->active_jobs[ACTIVE_JOB_HASH(kev->ident)], hash_sle) { + SLIST_FOREACH(ji, &jm->active_jobs[ACTIVE_JOB_HASH(kev->ident)], pid_hash_sle) { if (ji->p != (pid_t)kev->ident) { continue; } @@ -1936,6 +1944,7 @@ kev->udata = ji; job_callback(ji, kev); + /* A given PID exists only once per jobmgr_t */ break; } } @@ -2083,7 +2092,7 @@ break; default: total_children++; - SLIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, hash_sle); + SLIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, pid_hash_sle); if (!j->legacy_mach_job) { job_assumes(j, close(oepair[1]) != -1); @@ -3562,8 +3571,11 @@ } if (name) { + char thelabel[1000]; + + snprintf(thelabel, sizeof(thelabel), "com.apple.launchctl.%s", name); /* no name implies: bootstrap_subset() where creating a "bootstrapper" makes no sense */ - bootstrapper = job_new(jmr, "com.apple.launchctld", NULL, bootstrap_tool); + bootstrapper = job_new(jmr, thelabel, NULL, bootstrap_tool); if (jobmgr_assumes(jmr, bootstrapper != NULL) && (jm || getuid())) { char buf[100]; @@ -4713,15 +4725,18 @@ if (getuid() == 0) { const char *bootstrap_tool[] = { "/bin/launchctl", "bootstrap", "-S", session_type, NULL }; + char thelabel[1000]; job_t bootstrapper; + snprintf(thelabel, sizeof(thelabel), "com.apple.launchctl.%s", session_type); + job_assumes(j, (j2 = job_mig_intran2(root_jobmgr, target_subset)) != NULL); j = j2; jobmgr_log(j->mgr, LOG_DEBUG, "Renaming to: %s", session_type); strcpy(j->mgr->name, session_type); job_assumes(j, launchd_mport_deallocate(target_subset) == KERN_SUCCESS); - bootstrapper = job_new(j->mgr, "com.apple.launchctld", NULL, bootstrap_tool); + bootstrapper = job_new(j->mgr, thelabel, NULL, bootstrap_tool); if (job_assumes(j, bootstrapper != NULL)) { job_dispatch(bootstrapper, true); } @@ -5084,3 +5099,19 @@ { launchd_assert((root_jobmgr = jobmgr_new(NULL, MACH_PORT_NULL, MACH_PORT_NULL, sflag, getpid() == 1 ? "System" : "Background")) != NULL); } + +size_t +hash_label(const char *label) +{ + size_t c, r = 5381; + + /* djb2 + * This algorithm was first reported by Dan Bernstein many years ago in comp.lang.c + */ + + while ((c = *label++)) { + r = ((r << 5) + r) + c; /* hash*33 + c */ + } + + return r % LABEL_HASH_SIZE; +} Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-03-21 00:54:01 UTC (rev 23163) +++ trunk/launchd/src/launchd_core_logic.h 2007-03-21 18:35:06 UTC (rev 23164) @@ -31,7 +31,6 @@ void jobmgr_init(bool); jobmgr_t jobmgr_shutdown(jobmgr_t jm); void jobmgr_dispatch_all_semaphores(jobmgr_t jm); -job_t jobmgr_find(jobmgr_t jm, const char *label); jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port); bool jobmgr_ack_port_destruction(jobmgr_t jm, mach_port_t p); job_t jobmgr_find_by_service_port(jobmgr_t jm, mach_port_t p); @@ -39,6 +38,7 @@ launch_data_t job_export_all(void); job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */ +job_t job_find(const char *label); bool job_active(job_t j); bool job_is_anonymous(job_t j); launch_data_t job_export(job_t j); Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2007-03-21 00:54:01 UTC (rev 23163) +++ trunk/launchd/src/launchd_unix_ipc.c 2007-03-21 18:35:06 UTC (rev 23164) @@ -393,19 +393,19 @@ launch_data_set_bool(resp, batch_disabler_count == 0); } } else if (!strcmp(cmd, LAUNCH_KEY_STARTJOB)) { - if ((j = jobmgr_find(root_jobmgr, launch_data_get_string(data))) != NULL) { + if ((j = job_find(launch_data_get_string(data))) != NULL) { job_dispatch(j, true); errno = 0; } resp = launch_data_new_errno(errno); } else if (!strcmp(cmd, LAUNCH_KEY_STOPJOB)) { - if ((j = jobmgr_find(root_jobmgr, launch_data_get_string(data))) != NULL) { + if ((j = job_find(launch_data_get_string(data))) != NULL) { job_stop(j); errno = 0; } resp = launch_data_new_errno(errno); } else if (!strcmp(cmd, LAUNCH_KEY_REMOVEJOB)) { - if ((j = jobmgr_find(root_jobmgr, launch_data_get_string(data))) != NULL) { + if ((j = job_find(launch_data_get_string(data))) != NULL) { job_remove(j); errno = 0; } @@ -428,14 +428,14 @@ } else if (!strcmp(cmd, LAUNCH_KEY_SETRESOURCELIMITS)) { resp = adjust_rlimits(data); } else if (!strcmp(cmd, LAUNCH_KEY_GETJOB)) { - if ((j = jobmgr_find(root_jobmgr, launch_data_get_string(data))) == NULL) { + if ((j = job_find(launch_data_get_string(data))) == NULL) { resp = launch_data_new_errno(errno); } else { resp = job_export(j); ipc_revoke_fds(resp); } } else if (!strcmp(cmd, LAUNCH_KEY_GETJOBWITHHANDLES)) { - if ((j = jobmgr_find(root_jobmgr, launch_data_get_string(data))) == NULL) { + if ((j = job_find(launch_data_get_string(data))) == NULL) { resp = launch_data_new_errno(errno); } else { resp = job_export(j); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070321/bc4ccb9a/attachment.html From source_changes at macosforge.org Wed Mar 21 11:57:24 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23165] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070321185724.DFAD44F139E@cvs.opensource.apple.com> Revision: 23165 http://trac.macosforge.org/projects/launchd/changeset/23165 Author: zarzycki@apple.com Date: 2007-03-21 11:57:24 -0700 (Wed, 21 Mar 2007) Log Message: ----------- the MIG per user launchd lookup API only makes sense when called to PID 1. 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-03-21 18:35:06 UTC (rev 23164) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-21 18:57:24 UTC (rev 23165) @@ -4396,6 +4396,10 @@ return BOOTSTRAP_NO_MEMORY; } + if (getpid() != 1) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + runtime_get_caller_creds(&ldc); if (ldc.euid || ldc.uid) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070321/e3547c6d/attachment.html From source_changes at macosforge.org Wed Mar 21 13:54:17 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23166] tags/launchd-205/ Message-ID: <20070321205417.621BF4F14C7@cvs.opensource.apple.com> Revision: 23166 http://trac.macosforge.org/projects/launchd/changeset/23166 Author: zarzycki@apple.com Date: 2007-03-21 13:54:17 -0700 (Wed, 21 Mar 2007) Log Message: ----------- "Tagging launchd-205 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-205/ Copied: tags/launchd-205 (from rev 23165, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070321/3b47b858/attachment.html From source_changes at macosforge.org Wed Mar 21 21:06:04 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23167] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070322040604.F1FD94F1A2D@cvs.opensource.apple.com> Revision: 23167 http://trac.macosforge.org/projects/launchd/changeset/23167 Author: zarzycki@apple.com Date: 2007-03-21 21:06:04 -0700 (Wed, 21 Mar 2007) Log Message: ----------- More hashing for fun and profit. 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-03-21 20:54:17 UTC (rev 23166) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 04:06:04 UTC (rev 23167) @@ -100,10 +100,11 @@ struct machservice { SLIST_ENTRY(machservice) sle; + SLIST_ENTRY(machservice) hash_sle; job_t job; mach_port_name_t port; unsigned int isActive:1, reset:1, recv:1, hide:1, kUNCServer:1, must_match_uid:1, debug_on_close:1, per_pid:1; - char name[0]; + const char name[0]; }; static void machservice_setup(launch_data_t obj, const char *key, void *context); @@ -112,7 +113,7 @@ static struct machservice *machservice_new(job_t j, const char *name, mach_port_t *serviceport, bool pid_local); static void machservice_ignore(job_t j, struct machservice *ms); static void machservice_watch(job_t j, struct machservice *ms); -static void machservice_delete(struct machservice *); +static void machservice_delete(job_t j, struct machservice *); static void machservice_request_notifications(struct machservice *); static mach_port_t machservice_port(struct machservice *); static job_t machservice_job(struct machservice *); @@ -196,6 +197,7 @@ #define IS_POWER_OF_TWO(v) (!(v & (v - 1)) && v) #define ACTIVE_JOB_HASH_SIZE 32 #define ACTIVE_JOB_HASH(x) (IS_POWER_OF_TWO(ACTIVE_JOB_HASH_SIZE) ? (x & (ACTIVE_JOB_HASH_SIZE - 1)) : (x % ACTIVE_JOB_HASH_SIZE)) +#define MACHSERVICE_HASH_SIZE 37 struct jobmgr_s { kq_callback kqjobmgr_callback; @@ -203,6 +205,7 @@ SLIST_HEAD(, jobmgr_s) submgrs; SLIST_HEAD(, job_s) jobs; SLIST_HEAD(, job_s) active_jobs[ACTIVE_JOB_HASH_SIZE]; + SLIST_HEAD(, machservice) ms_hash[MACHSERVICE_HASH_SIZE]; mach_port_t jm_port; mach_port_t req_port; jobmgr_t parentmgr; @@ -292,7 +295,8 @@ #define LABEL_HASH_SIZE 53 SLIST_HEAD(, job_s) label_hash[LABEL_HASH_SIZE]; -static size_t hash_label(const char *label); +static size_t hash_label(const char *label) __attribute__((pure)); +static size_t hash_ms(const char *msstr) __attribute__((pure)); #define job_assumes(j, e) \ @@ -366,6 +370,7 @@ static unsigned int total_children; static int dir_has_files(job_t j, const char *path); static char **mach_cmd2argv(const char *string); +static size_t our_strhash(const char *s) __attribute__((pure)); jobmgr_t root_jobmgr; void @@ -679,7 +684,7 @@ limititem_delete(j, li); } while ((ms = SLIST_FIRST(&j->machservices))) { - machservice_delete(ms); + machservice_delete(j, ms); } while ((si = SLIST_FIRST(&j->semaphores))) { semaphoreitem_delete(j, si); @@ -3213,7 +3218,7 @@ return NULL; } - strcpy(ms->name, name); + strcpy((char *)ms->name, name); ms->job = j; ms->per_pid = pid_local; @@ -3233,6 +3238,7 @@ } SLIST_INSERT_HEAD(&j->machservices, ms, sle); + SLIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(ms->name)], ms, hash_sle); job_log(j, LOG_INFO, "Mach service added: %s", name); @@ -3632,7 +3638,7 @@ SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { SLIST_FOREACH_SAFE(ms, &ji->machservices, sle, next_ms) { if (ms->port == port) { - machservice_delete(ms); + machservice_delete(ji, ms); } } } @@ -3648,21 +3654,15 @@ jobmgr_lookup_service(jobmgr_t jm, const char *name, bool check_parent, pid_t target_pid) { struct machservice *ms; - job_t ji; if (target_pid) { jobmgr_assumes(jm, !check_parent); } - SLIST_FOREACH(ji, &jm->jobs, sle) { - if (target_pid && (ji->p != target_pid)) { - continue; - } - SLIST_FOREACH(ms, &ji->machservices, sle) { - if ((target_pid && ms->per_pid) || (!target_pid && !ms->per_pid)) { - if (strcmp(name, ms->name) == 0) { - return ms; - } + SLIST_FOREACH(ms, &jm->ms_hash[hash_ms(name)], hash_sle) { + if ((target_pid && ms->per_pid && ms->job->p == target_pid) || (!target_pid && !ms->per_pid)) { + if (strcmp(name, ms->name) == 0) { + return ms; } } } @@ -3709,22 +3709,23 @@ } void -machservice_delete(struct machservice *ms) +machservice_delete(job_t j, struct machservice *ms) { if (ms->debug_on_close) { - job_log(ms->job, LOG_NOTICE, "About to enter kernel debugger because of Mach port: 0x%x", ms->port); - job_assumes(ms->job, host_reboot(mach_host_self(), HOST_REBOOT_DEBUGGER) == KERN_SUCCESS); + job_log(j, LOG_NOTICE, "About to enter kernel debugger because of Mach port: 0x%x", ms->port); + job_assumes(j, host_reboot(mach_host_self(), HOST_REBOOT_DEBUGGER) == KERN_SUCCESS); } - if (ms->recv && job_assumes(ms->job, !ms->isActive)) { - job_assumes(ms->job, launchd_mport_close_recv(ms->port) == KERN_SUCCESS); + if (ms->recv && job_assumes(j, !ms->isActive)) { + job_assumes(j, launchd_mport_close_recv(ms->port) == KERN_SUCCESS); } - job_assumes(ms->job, launchd_mport_deallocate(ms->port) == KERN_SUCCESS); + job_assumes(j, launchd_mport_deallocate(ms->port) == KERN_SUCCESS); - job_log(ms->job, LOG_INFO, "Mach service deleted: %s", ms->name); + job_log(j, LOG_INFO, "Mach service deleted: %s", ms->name); - SLIST_REMOVE(&ms->job->machservices, ms, machservice, sle); + SLIST_REMOVE(&j->machservices, ms, machservice, sle); + SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(ms->name)], ms, machservice, hash_sle); free(ms); } @@ -4538,8 +4539,8 @@ job_log(j, LOG_DEBUG, "Mach service registration failed. Already active: %s", servicename); return BOOTSTRAP_SERVICE_ACTIVE; } - job_checkin(machservice_job(ms)); - machservice_delete(ms); + job_checkin(j); + machservice_delete(j, ms); } if (serviceport != MACH_PORT_NULL) { @@ -4709,9 +4710,19 @@ } if (job_assumes(j, jmi != NULL)) { + struct machservice *msi; + + SLIST_FOREACH(msi, &j->machservices, sle) { + SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(msi->name)], msi, machservice, hash_sle); + } + SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); SLIST_INSERT_HEAD(&jmi->jobs, j, sle); j->mgr = jmi; + + SLIST_FOREACH(msi, &j->machservices, sle) { + SLIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(msi->name)], msi, hash_sle); + } } } @@ -5105,7 +5116,7 @@ } size_t -hash_label(const char *label) +our_strhash(const char *s) { size_t c, r = 5381; @@ -5113,9 +5124,21 @@ * This algorithm was first reported by Dan Bernstein many years ago in comp.lang.c */ - while ((c = *label++)) { + while ((c = *s++)) { r = ((r << 5) + r) + c; /* hash*33 + c */ } - return r % LABEL_HASH_SIZE; + return r; } + +size_t +hash_label(const char *label) +{ + return our_strhash(label) % LABEL_HASH_SIZE; +} + +size_t +hash_ms(const char *msstr) +{ + return our_strhash(msstr) % MACHSERVICE_HASH_SIZE; +} -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070321/98604f78/attachment.html From source_changes at macosforge.org Thu Mar 22 09:18:32 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23168] trunk/launchd/src Message-ID: <20070322161832.9B5174F2136@cvs.opensource.apple.com> Revision: 23168 http://trac.macosforge.org/projects/launchd/changeset/23168 Author: zarzycki@apple.com Date: 2007-03-22 09:18:32 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Even more hashed lookups. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-22 04:06:04 UTC (rev 23167) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 16:18:32 UTC (rev 23168) @@ -94,19 +94,27 @@ #define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20 #define LAUNCHD_SIGKILL_TIMER 5 +#define IS_POWER_OF_TWO(v) (!(v & (v - 1)) && v) + extern char **environ; mach_port_t inherited_bootstrap_port; struct machservice { SLIST_ENTRY(machservice) sle; - SLIST_ENTRY(machservice) hash_sle; + SLIST_ENTRY(machservice) name_hash_sle; + SLIST_ENTRY(machservice) port_hash_sle; job_t job; mach_port_name_t port; unsigned int isActive:1, reset:1, recv:1, hide:1, kUNCServer:1, must_match_uid:1, debug_on_close:1, per_pid:1; const char name[0]; }; +#define PORT_HASH_SIZE 32 +#define HASH_PORT(x) (IS_POWER_OF_TWO(PORT_HASH_SIZE) ? (MACH_PORT_INDEX(x) & (PORT_HASH_SIZE - 1)) : (MACH_PORT_INDEX(x) % PORT_HASH_SIZE)) + +SLIST_HEAD(, machservice) port_hash[PORT_HASH_SIZE]; + static void machservice_setup(launch_data_t obj, const char *key, void *context); static void machservice_setup_options(launch_data_t obj, const char *key, void *context); static void machservice_resetport(job_t j, struct machservice *ms); @@ -194,7 +202,6 @@ static void semaphoreitem_watch(job_t j, struct semaphoreitem *si); static void semaphoreitem_ignore(job_t j, struct semaphoreitem *si); -#define IS_POWER_OF_TWO(v) (!(v & (v - 1)) && v) #define ACTIVE_JOB_HASH_SIZE 32 #define ACTIVE_JOB_HASH(x) (IS_POWER_OF_TWO(ACTIVE_JOB_HASH_SIZE) ? (x & (ACTIVE_JOB_HASH_SIZE - 1)) : (x % ACTIVE_JOB_HASH_SIZE)) #define MACHSERVICE_HASH_SIZE 37 @@ -1614,26 +1621,16 @@ } job_t -jobmgr_find_by_service_port(jobmgr_t jm, mach_port_t p) +job_find_by_service_port(mach_port_t p) { struct machservice *ms; - jobmgr_t jmi; - job_t ji, jr; - SLIST_FOREACH(jmi, &jm->submgrs, sle) { - if ((jr = jobmgr_find_by_service_port(jmi, p))) { - return jr; + SLIST_FOREACH(ms, &port_hash[HASH_PORT(p)], port_hash_sle) { + if (ms->port == p) { + return ms->job; } } - SLIST_FOREACH(ji, &jm->jobs, sle) { - SLIST_FOREACH(ms, &ji->machservices, sle) { - if (ms->port == p) { - return ji; - } - } - } - return NULL; } @@ -3203,10 +3200,12 @@ void machservice_resetport(job_t j, struct machservice *ms) { + SLIST_REMOVE(&port_hash[HASH_PORT(ms->port)], ms, machservice, port_hash_sle); job_assumes(j, launchd_mport_close_recv(ms->port) == KERN_SUCCESS); job_assumes(j, launchd_mport_deallocate(ms->port) == KERN_SUCCESS); job_assumes(j, launchd_mport_create_recv(&ms->port) == KERN_SUCCESS); job_assumes(j, launchd_mport_make_send(ms->port) == KERN_SUCCESS); + SLIST_INSERT_HEAD(&port_hash[HASH_PORT(ms->port)], ms, port_hash_sle); } struct machservice * @@ -3238,7 +3237,8 @@ } SLIST_INSERT_HEAD(&j->machservices, ms, sle); - SLIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(ms->name)], ms, hash_sle); + SLIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(ms->name)], ms, name_hash_sle); + SLIST_INSERT_HEAD(&port_hash[HASH_PORT(ms->port)], ms, port_hash_sle); job_log(j, LOG_INFO, "Mach service added: %s", name); @@ -3619,7 +3619,6 @@ { struct machservice *ms, *next_ms; jobmgr_t jmi, jmn; - job_t ji, jn; /* Mach ports, unlike Unix descriptors, are reference counted. In other * words, when some program hands us a second or subsequent send right @@ -3631,18 +3630,18 @@ * to use. */ - SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { - jobmgr_delete_anything_with_port(jmi, port); - } - - SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { - SLIST_FOREACH_SAFE(ms, &ji->machservices, sle, next_ms) { + if (jm == root_jobmgr) { + SLIST_FOREACH_SAFE(ms, &port_hash[HASH_PORT(port)], port_hash_sle, next_ms) { if (ms->port == port) { - machservice_delete(ji, ms); + machservice_delete(ms->job, ms); } } } + SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { + jobmgr_delete_anything_with_port(jmi, port); + } + if (jm->req_port == port) { return jobmgr_shutdown(jm); } @@ -3659,7 +3658,7 @@ jobmgr_assumes(jm, !check_parent); } - SLIST_FOREACH(ms, &jm->ms_hash[hash_ms(name)], hash_sle) { + SLIST_FOREACH(ms, &jm->ms_hash[hash_ms(name)], name_hash_sle) { if ((target_pid && ms->per_pid && ms->job->p == target_pid) || (!target_pid && !ms->per_pid)) { if (strcmp(name, ms->name) == 0) { return ms; @@ -3725,7 +3724,8 @@ job_log(j, LOG_INFO, "Mach service deleted: %s", ms->name); SLIST_REMOVE(&j->machservices, ms, machservice, sle); - SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(ms->name)], ms, machservice, hash_sle); + SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(ms->name)], ms, machservice, name_hash_sle); + SLIST_REMOVE(&port_hash[HASH_PORT(ms->port)], ms, machservice, port_hash_sle); free(ms); } @@ -3805,38 +3805,29 @@ } bool -jobmgr_ack_port_destruction(jobmgr_t jm, mach_port_t p) +job_ack_port_destruction(mach_port_t p) { - struct machservice *ms = NULL; - jobmgr_t jmi; - job_t ji; + struct machservice *ms; - SLIST_FOREACH(jmi, &jm->submgrs, sle) { - if (jobmgr_ack_port_destruction(jmi, p)) { - return true; + SLIST_FOREACH(ms, &port_hash[HASH_PORT(p)], port_hash_sle) { + if (ms->port == p) { + break; } } - /* We don't need the _SAFE version because we return after the job_dispatch() */ - SLIST_FOREACH(ji, &jm->jobs, sle) { - SLIST_FOREACH(ms, &ji->machservices, sle) { - if (ms->port != p) { - continue; - } + if (!ms) { + return false; + } - ms->isActive = false; + ms->isActive = false; - if (ms->reset) { - machservice_resetport(ji, ms); - } - - job_log(ji, LOG_DEBUG, "Receive right returned to us: %s", ms->name); - job_dispatch(ji, false); - return true; - } + if (ms->reset) { + machservice_resetport(ms->job, ms); } - return false; + job_log(ms->job, LOG_DEBUG, "Receive right returned to us: %s", ms->name); + job_dispatch(ms->job, false); + return true; } void @@ -4713,7 +4704,7 @@ struct machservice *msi; SLIST_FOREACH(msi, &j->machservices, sle) { - SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(msi->name)], msi, machservice, hash_sle); + SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(msi->name)], msi, machservice, name_hash_sle); } SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); @@ -4721,7 +4712,7 @@ j->mgr = jmi; SLIST_FOREACH(msi, &j->machservices, sle) { - SLIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(msi->name)], msi, hash_sle); + SLIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(msi->name)], msi, name_hash_sle); } } } Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-03-22 04:06:04 UTC (rev 23167) +++ trunk/launchd/src/launchd_core_logic.h 2007-03-22 16:18:32 UTC (rev 23168) @@ -32,13 +32,13 @@ jobmgr_t jobmgr_shutdown(jobmgr_t jm); void jobmgr_dispatch_all_semaphores(jobmgr_t jm); jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port); -bool jobmgr_ack_port_destruction(jobmgr_t jm, mach_port_t p); -job_t jobmgr_find_by_service_port(jobmgr_t jm, mach_port_t p); launch_data_t job_export_all(void); job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */ job_t job_find(const char *label); +job_t job_find_by_service_port(mach_port_t p); +bool job_ack_port_destruction(mach_port_t p); bool job_active(job_t j); bool job_is_anonymous(job_t j); launch_data_t job_export(job_t j); Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-22 04:06:04 UTC (rev 23167) +++ trunk/launchd/src/launchd_runtime.c 2007-03-22 16:18:32 UTC (rev 23168) @@ -419,7 +419,7 @@ continue; } if (status.mps_msgcount) { - EV_SET(&kev, members[i], EVFILT_MACHPORT, 0, 0, 0, jobmgr_find_by_service_port(root_jobmgr, members[i])); + EV_SET(&kev, members[i], EVFILT_MACHPORT, 0, 0, 0, job_find_by_service_port(members[i])); #if 0 if (launchd_assumes(kev.udata != NULL)) { #endif @@ -709,7 +709,7 @@ { /* This message is sent to us when a receive right is returned to us. */ - if (!jobmgr_ack_port_destruction(root_jobmgr, rights)) { + if (!launchd_assumes(job_ack_port_destruction(rights))) { launchd_assumes(launchd_mport_close_recv(rights) == KERN_SUCCESS); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/9137f4c4/attachment.html From source_changes at macosforge.org Thu Mar 22 09:26:30 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23169] trunk/launchd/src/launchd_runtime.c Message-ID: <20070322162630.D7A594F214D@cvs.opensource.apple.com> Revision: 23169 http://trac.macosforge.org/projects/launchd/changeset/23169 Author: zarzycki@apple.com Date: 2007-03-22 09:26:30 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Workaround for syslogd crashing. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-22 16:18:32 UTC (rev 23168) +++ trunk/launchd/src/launchd_runtime.c 2007-03-22 16:26:30 UTC (rev 23169) @@ -971,7 +971,8 @@ size_t i, j; if (!(debug_shutdown_hangs && getpid() == 1)) { - return vsyslog(priority, message, args); + vsyslog(priority, message, args); + return closelog(); } if (shutdown_start.tv_sec == 0) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/1dbe5a84/attachment.html From source_changes at macosforge.org Thu Mar 22 09:43:37 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23170] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070322164337.6FB8A4F2173@cvs.opensource.apple.com> Revision: 23170 http://trac.macosforge.org/projects/launchd/changeset/23170 Author: zarzycki@apple.com Date: 2007-03-22 09:43:36 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Now that we're creating anonymous jobs on the fly per PID, we don't need this added logging information. 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-03-22 16:26:30 UTC (rev 23169) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 16:43:36 UTC (rev 23170) @@ -4575,16 +4575,16 @@ if (ms) { launchd_assumes(machservice_port(ms) != MACH_PORT_NULL); - job_log(j, LOG_DEBUG, "%sMach service lookup (by PID %d): %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", ldc.pid, servicename); + job_log(j, LOG_DEBUG, "%sMach service lookup: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); *serviceportp = machservice_port(ms); *ptype = MACH_MSG_TYPE_COPY_SEND; return BOOTSTRAP_SUCCESS; } else if (!(flags & BOOTSTRAP_PER_PID_SERVICE) && (inherited_bootstrap_port != MACH_PORT_NULL)) { - job_log(j, LOG_DEBUG, "Mach service lookup (by PID %d) forwarded: %s", ldc.pid, servicename); + job_log(j, LOG_DEBUG, "Mach service lookup forwarded: %s", servicename); *ptype = MACH_MSG_TYPE_MOVE_SEND; return bootstrap_look_up(inherited_bootstrap_port, servicename, serviceportp); } else { - job_log(j, LOG_DEBUG, "%sMach service lookup (by PID %d) failed: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", ldc.pid, servicename); + job_log(j, LOG_DEBUG, "%sMach service lookup failed: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); return BOOTSTRAP_UNKNOWN_SERVICE; } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/b0672427/attachment.html From source_changes at macosforge.org Thu Mar 22 11:18:17 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:44 2007 Subject: [launchd-changes] [23171] trunk/launchd/src Message-ID: <20070322181817.62B954F2216@cvs.opensource.apple.com> Revision: 23171 http://trac.macosforge.org/projects/launchd/changeset/23171 Author: zarzycki@apple.com Date: 2007-03-22 11:18:17 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Better logging for after Leopard ships. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-22 16:43:36 UTC (rev 23170) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 18:18:17 UTC (rev 23171) @@ -105,8 +105,10 @@ SLIST_ENTRY(machservice) name_hash_sle; SLIST_ENTRY(machservice) port_hash_sle; job_t job; + uint64_t bad_perf_cnt; + unsigned int gen_num; mach_port_name_t port; - unsigned int isActive:1, reset:1, recv:1, hide:1, kUNCServer:1, must_match_uid:1, debug_on_close:1, per_pid:1; + unsigned int isActive:1, reset:1, recv:1, hide:1, kUNCServer:1, per_user_hack:1, debug_on_close:1, per_pid:1; const char name[0]; }; @@ -276,6 +278,8 @@ char *groupname; char *stdoutpath; char *stderrpath; + struct machservice *lastlookup; + unsigned int lastlookup_gennum; pid_t p; int argc; int last_exit_status; @@ -295,7 +299,8 @@ 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, removal_pending:1, - wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1; + wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, + per_user:1; const char label[0]; }; @@ -3203,6 +3208,7 @@ SLIST_REMOVE(&port_hash[HASH_PORT(ms->port)], ms, machservice, port_hash_sle); job_assumes(j, launchd_mport_close_recv(ms->port) == KERN_SUCCESS); job_assumes(j, launchd_mport_deallocate(ms->port) == KERN_SUCCESS); + ms->gen_num++; job_assumes(j, launchd_mport_create_recv(&ms->port) == KERN_SUCCESS); job_assumes(j, launchd_mport_make_send(ms->port) == KERN_SUCCESS); SLIST_INSERT_HEAD(&port_hash[HASH_PORT(ms->port)], ms, port_hash_sle); @@ -4405,13 +4411,16 @@ *up_cont = MACH_PORT_NULL; SLIST_FOREACH(ji, &root_jobmgr->jobs, sle) { + if (!ji->per_user) { + continue; + } if (ji->mach_uid != which_user) { continue; } if (SLIST_EMPTY(&ji->machservices)) { continue; } - if (!SLIST_FIRST(&ji->machservices)->must_match_uid) { + if (!SLIST_FIRST(&ji->machservices)->per_user_hack) { continue; } break; @@ -4430,13 +4439,14 @@ } ji->mach_uid = which_user; + ji->per_user = true; if ((ms = machservice_new(ji, lbuf, up_cont, false)) == NULL) { job_remove(ji); return BOOTSTRAP_NO_MEMORY; } - ms->must_match_uid = true; + ms->per_user_hack = true; ms->hide = true; ji = job_dispatch(ji, false); @@ -4502,7 +4512,7 @@ runtime_get_caller_creds(&ldc); #if 0 - job_log(j, LOG_NOTICE, "bootstrap_register() is deprecated. PID: %u Service: %s", ldc.pid, servicename); + job_log(j, LOG_APPLEONLY, "bootstrap_register() is deprecated. Service: %s", servicename); #endif job_log(j, LOG_DEBUG, "%sMach service registration attempt: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); @@ -4550,6 +4560,7 @@ { struct machservice *ms; struct ldcred ldc; + kern_return_t kr; if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; @@ -4569,24 +4580,36 @@ if (ms && machservice_hidden(ms) && !job_active(machservice_job(ms))) { ms = NULL; - } else if (ms && ms->must_match_uid) { + } else if (ms && ms->per_user_hack) { ms = NULL; } if (ms) { launchd_assumes(machservice_port(ms) != MACH_PORT_NULL); job_log(j, LOG_DEBUG, "%sMach service lookup: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); +#if 0 + /* After Leopard ships, we should enable this */ + if (j->lastlookup == ms && j->lastlookup_gennum == ms->gen_num && !j->per_user) { + ms->bad_perf_cnt++; + job_log(j, LOG_APPLEONLY, "Performance opportunity: Number of bootstrap_lookup(... \"%s\" ...) calls that should have been cached: %llu", + servicename, ms->bad_perf_cnt); + } + j->lastlookup = ms; + j->lastlookup_gennum = ms->gen_num; +#endif *serviceportp = machservice_port(ms); *ptype = MACH_MSG_TYPE_COPY_SEND; - return BOOTSTRAP_SUCCESS; + kr = BOOTSTRAP_SUCCESS; } else if (!(flags & BOOTSTRAP_PER_PID_SERVICE) && (inherited_bootstrap_port != MACH_PORT_NULL)) { job_log(j, LOG_DEBUG, "Mach service lookup forwarded: %s", servicename); *ptype = MACH_MSG_TYPE_MOVE_SEND; - return bootstrap_look_up(inherited_bootstrap_port, servicename, serviceportp); + kr = bootstrap_look_up(inherited_bootstrap_port, servicename, serviceportp); } else { job_log(j, LOG_DEBUG, "%sMach service lookup failed: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); - return BOOTSTRAP_UNKNOWN_SERVICE; + kr = BOOTSTRAP_UNKNOWN_SERVICE; } + + return kr; } kern_return_t Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-22 16:43:36 UTC (rev 23170) +++ trunk/launchd/src/launchd_runtime.c 2007-03-22 18:18:17 UTC (rev 23171) @@ -964,13 +964,25 @@ { static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER; static struct timeval shutdown_start = { 0, 0 }; + static int apple_internal_logging = 1; struct timeval tvnow, tvd; + struct stat sb; int saved_errno = errno; char newmsg[10000]; double float_time; size_t i, j; + if (apple_internal_logging == 1) { + apple_internal_logging = stat("/AppleInternal", &sb); + } + if (!(debug_shutdown_hangs && getpid() == 1)) { + if (priority == LOG_APPLEONLY) { + if (apple_internal_logging == -1) { + return; + } + priority = LOG_NOTICE; + } vsyslog(priority, message, args); return closelog(); } Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-03-22 16:43:36 UTC (rev 23170) +++ trunk/launchd/src/launchd_runtime.h 2007-03-22 18:18:17 UTC (rev 23171) @@ -76,6 +76,8 @@ void runtime_openlog(const char *ident, int logopt, int facility); void runtime_closelog(void); +#define LOG_APPLEONLY 0x4141504c /* AAPL in hex */ + int runtime_setlogmask(int maskpri); void runtime_syslog(int priority, const char *message, ...) __attribute__((format(printf, 2, 3))); void runtime_vsyslog(int priority, const char *message, va_list args) __attribute__((format(printf, 2, 0))); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/26d46594/attachment.html From source_changes at macosforge.org Thu Mar 22 11:31:28 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23172] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070322183128.C7F324F22B7@cvs.opensource.apple.com> Revision: 23172 http://trac.macosforge.org/projects/launchd/changeset/23172 Author: zarzycki@apple.com Date: 2007-03-22 11:31:28 -0700 (Thu, 22 Mar 2007) Log Message: ----------- A quick and dirty way to extract the jobmgr_t that a job is in when doing "launchctl list " 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-03-22 18:18:17 UTC (rev 23171) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 18:31:28 UTC (rev 23172) @@ -469,6 +469,9 @@ if ((tmp = launch_data_new_string(j->label))) { launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_LABEL); } + if ((tmp = launch_data_new_string(j->mgr->name))) { + launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE); + } if ((tmp = launch_data_new_bool(j->ondemand))) { launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_ONDEMAND); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/64265455/attachment.html From source_changes at macosforge.org Thu Mar 22 11:40:59 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23173] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070322184059.6341B4F22CB@cvs.opensource.apple.com> Revision: 23173 http://trac.macosforge.org/projects/launchd/changeset/23173 Author: zarzycki@apple.com Date: 2007-03-22 11:40:59 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Anonymous jobs that execve() should be forgotten. 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-03-22 18:31:28 UTC (rev 23172) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 18:40:59 UTC (rev 23173) @@ -956,7 +956,7 @@ jr->p = anonpid; /* anonymous process reaping is messy */ SLIST_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_EXIT, 0, root_jobmgr) != -1); + job_assumes(jr, kevent_mod(jr->p, EVFILT_PROC, EV_ADD, NOTE_EXEC|NOTE_EXIT, 0, root_jobmgr) != -1); job_log(jr, LOG_DEBUG, "Created anonymously."); } @@ -1880,6 +1880,10 @@ { if (fflags & NOTE_EXEC) { job_log(j, LOG_DEBUG, "Called execve()"); + if (j->anonymous) { + job_reap(j); + job_remove(j); + } } if (fflags & NOTE_FORK) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/c4741b48/attachment.html From source_changes at macosforge.org Thu Mar 22 11:53:13 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23174] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070322185313.9B1C94F22FF@cvs.opensource.apple.com> Revision: 23174 http://trac.macosforge.org/projects/launchd/changeset/23174 Author: zarzycki@apple.com Date: 2007-03-22 11:53:13 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Paranoia now that we have the anonymous job concept. 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-03-22 18:40:59 UTC (rev 23173) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 18:53:13 UTC (rev 23174) @@ -212,7 +212,7 @@ kq_callback kqjobmgr_callback; SLIST_ENTRY(jobmgr_s) sle; SLIST_HEAD(, jobmgr_s) submgrs; - SLIST_HEAD(, job_s) jobs; + LIST_HEAD(, job_s) jobs; SLIST_HEAD(, job_s) active_jobs[ACTIVE_JOB_HASH_SIZE]; SLIST_HEAD(, machservice) ms_hash[MACHSERVICE_HASH_SIZE]; mach_port_t jm_port; @@ -251,7 +251,7 @@ struct job_s { kq_callback kqjob_callback; - SLIST_ENTRY(job_s) sle; + LIST_ENTRY(job_s) sle; SLIST_ENTRY(job_s) pid_hash_sle; SLIST_ENTRY(job_s) label_hash_sle; SLIST_HEAD(, socketgroup) sockets; @@ -581,7 +581,7 @@ jobmgr_shutdown(jmi); } - SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + LIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { if (!job_active(ji)) { job_remove(ji); } else if (!ji->hopefully_exits_last) { @@ -610,7 +610,7 @@ } } - while ((ji = SLIST_FIRST(&jm->jobs))) { + while ((ji = LIST_FIRST(&jm->jobs))) { /* We should only have anonymous jobs left */ job_assumes(ji, ji->anonymous); job_remove(ji); @@ -735,7 +735,7 @@ kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); - SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); + LIST_REMOVE(j, sle); SLIST_REMOVE(&label_hash[hash_label(j->label)], j, job_s, label_hash_sle); job_log(j, LOG_DEBUG, "Removed"); @@ -1041,7 +1041,7 @@ j->argv[i] = NULL; } - SLIST_INSERT_HEAD(&jm->jobs, j, sle); + LIST_INSERT_HEAD(&jm->jobs, j, sle); SLIST_INSERT_HEAD(&label_hash[hash_label(j->label)], j, label_hash_sle); job_log(j, LOG_DEBUG, "Conceived"); @@ -1597,7 +1597,7 @@ } } - SLIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->jobs, sle) { if (ji->j_port == p) { return ji; } @@ -1657,7 +1657,7 @@ job_export_all2(jmi, where); } - SLIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->jobs, sle) { launch_data_t tmp; if (jobmgr_assumes(jm, (tmp = job_export(ji)) != NULL)) { @@ -1796,7 +1796,7 @@ jobmgr_dispatch_all(jmi, newmounthack); } - SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + LIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { job_dispatch(ji, newmounthack ? ji->start_on_mount : false); } } @@ -2215,7 +2215,7 @@ jobmgr_setup_env_from_other_jobs(jm->parentmgr); } - SLIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ei, &ji->global_env, sle) { setenv(ei->key, ei->value, 1); } @@ -3407,7 +3407,7 @@ return jm; } - SLIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->jobs, sle) { if (ji->p && !ji->hopefully_exits_last) { return jm; } @@ -3415,7 +3415,7 @@ jobmgr_log(jm, LOG_DEBUG, "Asking \"hopeful\" jobs to exit."); - SLIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->jobs, sle) { job_stop(ji); } @@ -3475,7 +3475,7 @@ return false; } - SLIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->jobs, sle) { if (ji->p && !ji->anonymous) { return false; } @@ -4047,7 +4047,7 @@ jobmgr_dispatch_all_semaphores(jmi); } - SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + LIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { if (!SLIST_EMPTY(&ji->semaphores)) { job_dispatch(ji, false); } @@ -4417,7 +4417,7 @@ *up_cont = MACH_PORT_NULL; - SLIST_FOREACH(ji, &root_jobmgr->jobs, sle) { + LIST_FOREACH(ji, &root_jobmgr->jobs, sle) { if (!ji->per_user) { continue; } @@ -4659,7 +4659,7 @@ jm = j->mgr; - SLIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (!ms->per_pid) { cnt++; @@ -4681,7 +4681,7 @@ goto out_bad; } - SLIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (!ms->per_pid) { strlcpy(service_names[cnt2], machservice_name(ms), sizeof(service_names[0])); @@ -4737,8 +4737,8 @@ SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(msi->name)], msi, machservice, name_hash_sle); } - SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); - SLIST_INSERT_HEAD(&jmi->jobs, j, sle); + LIST_REMOVE(j, sle); + LIST_INSERT_HEAD(&jmi->jobs, j, sle); j->mgr = jmi; SLIST_FOREACH(msi, &j->machservices, sle) { @@ -4802,7 +4802,7 @@ struct machservice *ms; job_t j_for_service; - SLIST_FOREACH(j_for_service, &jmr->jobs, sle) { + LIST_FOREACH(j_for_service, &jmr->jobs, sle) { if (j_for_service->p == l2l_pids[l2l_i]) { break; } @@ -4867,7 +4867,7 @@ job_log(j, LOG_DEBUG, "Transferring sub-bootstrap to the per session launchd."); - SLIST_FOREACH(ji, &j->mgr->jobs, sle) { + LIST_FOREACH(ji, &j->mgr->jobs, sle) { if (!ji->anonymous) { continue; } @@ -4891,7 +4891,7 @@ goto out_bad; } - SLIST_FOREACH(ji, &j->mgr->jobs, sle) { + LIST_FOREACH(ji, &j->mgr->jobs, sle) { if (!ji->anonymous) { continue; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/c91839f6/attachment.html From source_changes at macosforge.org Thu Mar 22 12:51:57 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23175] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070322195157.A70C54F2454@cvs.opensource.apple.com> Revision: 23175 http://trac.macosforge.org/projects/launchd/changeset/23175 Author: zarzycki@apple.com Date: 2007-03-22 12:51:57 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Let's not cause a use after free. 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-03-22 18:53:13 UTC (rev 23174) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 19:51:57 UTC (rev 23175) @@ -1881,8 +1881,8 @@ if (fflags & NOTE_EXEC) { job_log(j, LOG_DEBUG, "Called execve()"); if (j->anonymous) { - job_reap(j); - job_remove(j); + flags |= EV_EOF|EV_ONESHOT; + fflags |= NOTE_EXIT; } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/dfd6632f/attachment.html From source_changes at macosforge.org Thu Mar 22 15:46:14 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23176] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070322224614.DE8814F272C@cvs.opensource.apple.com> Revision: 23176 http://trac.macosforge.org/projects/launchd/changeset/23176 Author: zarzycki@apple.com Date: 2007-03-22 15:46:14 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Dead code deletion. 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-03-22 19:51:57 UTC (rev 23175) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 22:46:14 UTC (rev 23176) @@ -3172,10 +3172,6 @@ { struct machservice *ms; - if (j->anonymous) { - return true; - } - if (j->wait4pipe_eof && j->log_redirect_fd) { return true; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/9db5f68d/attachment.html From source_changes at macosforge.org Thu Mar 22 15:53:09 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23177] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070322225309.B70934F2738@cvs.opensource.apple.com> Revision: 23177 http://trac.macosforge.org/projects/launchd/changeset/23177 Author: zarzycki@apple.com Date: 2007-03-22 15:53:09 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Leopard9A396: Terminal never finishes login. 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-03-22 22:46:14 UTC (rev 23176) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-22 22:53:09 UTC (rev 23177) @@ -4775,6 +4775,11 @@ return 0; } + if (getpid() != 1 && job_mig_intran2(root_jobmgr, target_subset)) { + job_assumes(j, launchd_mport_deallocate(target_subset) == KERN_SUCCESS); + return 0; + } + kr = _vproc_grab_subset(target_subset, &reqport, &rcvright, &l2l_names, &l2l_name_cnt, &l2l_pids, &l2l_pid_cnt, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/752b6e25/attachment.html From source_changes at macosforge.org Thu Mar 22 18:20:15 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23178] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070323012015.0F4274F2972@cvs.opensource.apple.com> Revision: 23178 http://trac.macosforge.org/projects/launchd/changeset/23178 Author: zarzycki@apple.com Date: 2007-03-22 18:20:14 -0700 (Thu, 22 Mar 2007) Log Message: ----------- CoreOS PreBuilds - xnu-1072.1 System refuses to shutdown 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-03-22 22:53:09 UTC (rev 23177) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-23 01:20:14 UTC (rev 23178) @@ -3404,7 +3404,7 @@ } LIST_FOREACH(ji, &jm->jobs, sle) { - if (ji->p && !ji->hopefully_exits_last) { + if (ji->p && !ji->anonymous && !ji->hopefully_exits_last) { return jm; } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/d2ebb3aa/attachment.html From source_changes at macosforge.org Thu Mar 22 18:42:16 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23179] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070323014216.2B9F14F29C7@cvs.opensource.apple.com> Revision: 23179 http://trac.macosforge.org/projects/launchd/changeset/23179 Author: zarzycki@apple.com Date: 2007-03-22 18:42:15 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Fix some hash corruption. 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-03-23 01:20:14 UTC (rev 23178) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-23 01:42:15 UTC (rev 23179) @@ -612,7 +612,9 @@ while ((ji = LIST_FIRST(&jm->jobs))) { /* We should only have anonymous jobs left */ - job_assumes(ji, ji->anonymous); + if (job_assumes(ji, ji->anonymous) && ji->p) { + job_reap(ji); + } job_remove(ji); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070322/33421b66/attachment.html From source_changes at macosforge.org Fri Mar 23 13:32:09 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23180] trunk/launchd/src Message-ID: <20070323203209.AA2C74F38EF@cvs.opensource.apple.com> Revision: 23180 http://trac.macosforge.org/projects/launchd/changeset/23180 Author: zarzycki@apple.com Date: 2007-03-23 13:32:08 -0700 (Fri, 23 Mar 2007) Log Message: ----------- Cache two unchanging values that CF calls a lot. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-23 01:42:15 UTC (rev 23179) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-23 20:32:08 UTC (rev 23180) @@ -4270,12 +4270,27 @@ kern_return_t job_mig_swap_integer(job_t j, vproc_gsk_t inkey, vproc_gsk_t outkey, int64_t inval, int64_t *outval) { + const char *action; kern_return_t kr = 0; if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } + if (inkey && outkey && !job_assumes(j, inkey == outkey)) { + return 1; + } + + if (inkey && outkey) { + action = "Swapping"; + } else if (inkey) { + action = "Setting"; + } else { + action = "Getting"; + } + + job_log(j, LOG_DEBUG, "%s key: %u", action, inkey ? inkey : outkey); + switch (outkey) { case VPROC_GSK_LAST_EXIT_STATUS: *outval = j->last_exit_status; @@ -4287,7 +4302,7 @@ *outval = getpid(); break; case VPROC_GSK_IS_MANAGED: - *outval = !j->anonymous; + *outval = j->anonymous ? 0 : 1; break; case VPROC_GSK_BASIC_KEEPALIVE: *outval = !j->ondemand; Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-03-23 01:42:15 UTC (rev 23179) +++ trunk/launchd/src/libvproc.c 2007-03-23 20:32:08 UTC (rev 23180) @@ -213,9 +213,38 @@ vproc_err_t vproc_swap_integer(vproc_t vp __attribute__((unused)), vproc_gsk_t key, int64_t *inval, int64_t *outval) { + static int64_t cached_pid = -1; + static int64_t cached_is_managed = -1; int64_t dummyval = 0; + switch (key) { + case VPROC_GSK_MGR_PID: + if (cached_pid != -1 && outval) { + *outval = cached_pid; + return NULL; + } + break; + case VPROC_GSK_IS_MANAGED: + if (cached_is_managed != -1 && outval) { + *outval = cached_is_managed; + return NULL; + } + break; + default: + break; + } + if (vproc_mig_swap_integer(bootstrap_port, inval ? key : 0, outval ? key : 0, inval ? *inval : 0, outval ? outval : &dummyval) == 0) { + switch (key) { + case VPROC_GSK_MGR_PID: + cached_pid = outval ? *outval : dummyval; + break; + case VPROC_GSK_IS_MANAGED: + cached_is_managed = outval ? *outval : dummyval; + break; + default: + break; + } return NULL; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070323/a9d22a00/attachment.html From source_changes at macosforge.org Fri Mar 23 13:33:05 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23181] tags/launchd-206/ Message-ID: <20070323203305.289C54F38F4@cvs.opensource.apple.com> Revision: 23181 http://trac.macosforge.org/projects/launchd/changeset/23181 Author: zarzycki@apple.com Date: 2007-03-23 13:33:04 -0700 (Fri, 23 Mar 2007) Log Message: ----------- "Tagging launchd-206 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-206/ Copied: tags/launchd-206 (from rev 23180, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070323/6d0ef514/attachment.html From source_changes at macosforge.org Sun Mar 25 12:52:03 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23182] trunk/launchd/src Message-ID: <20070325195203.C16C14F5B6E@cvs.opensource.apple.com> Revision: 23182 http://trac.macosforge.org/projects/launchd/changeset/23182 Author: zarzycki@apple.com Date: 2007-03-25 12:52:03 -0700 (Sun, 25 Mar 2007) Log Message: ----------- Add basic support for a job to be kept alive based on whether another job is running or not. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/liblaunch_public.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-23 20:33:04 UTC (rev 23181) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-25 19:52:03 UTC (rev 23182) @@ -184,6 +184,8 @@ FAILED_EXIT, PATH_EXISTS, PATH_MISSING, + OTHER_JOB_ACTIVE, + OTHER_JOB_INACTIVE, PATH_CHANGES, DIR_NOT_EMPTY, // FILESYSTEMTYPE_IS_MOUNTED, /* for nfsiod, but maybe others */ @@ -200,6 +202,7 @@ static void semaphoreitem_delete(job_t j, struct semaphoreitem *si); static void semaphoreitem_setup(launch_data_t obj, const char *key, void *context); static void semaphoreitem_setup_paths(launch_data_t obj, const char *key, void *context); +static void semaphoreitem_setup_otherjobs(launch_data_t obj, const char *key, void *context); static void semaphoreitem_callback(job_t j, struct kevent *kev); static void semaphoreitem_watch(job_t j, struct semaphoreitem *si); static void semaphoreitem_ignore(job_t j, struct semaphoreitem *si); @@ -3111,6 +3114,7 @@ SLIST_FOREACH(si, &j->semaphores, sle) { bool wanted_state = false; int qdir_file_cnt; + job_t other_j; switch (si->why) { case NETWORK_UP: @@ -3129,6 +3133,16 @@ return true; } break; + case OTHER_JOB_ACTIVE: + wanted_state = true; + case OTHER_JOB_INACTIVE: + if ((other_j = job_find(si->what))) { + if ((bool)other_j->p == wanted_state) { + job_log(j, LOG_DEBUG, "KeepAlive: The following job is %s: %s", wanted_state ? "active" : "inactive", si->what); + return true; + } + } + break; case PATH_EXISTS: wanted_state = true; case PATH_MISSING: @@ -4005,6 +4019,17 @@ } void +semaphoreitem_setup_otherjobs(launch_data_t obj, const char *key, void *context) +{ + job_t j = context; + semaphore_reason_t why; + + why = launch_data_get_bool(obj) ? OTHER_JOB_ACTIVE : OTHER_JOB_INACTIVE; + + semaphoreitem_new(j, why, key); +} + +void semaphoreitem_setup_paths(launch_data_t obj, const char *key, void *context) { job_t j = context; @@ -4031,6 +4056,9 @@ } else if (strcasecmp(key, LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE) == 0 && launch_data_get_type(obj) == LAUNCH_DATA_DICTIONARY) { launch_data_dict_iterate(obj, semaphoreitem_setup_paths, j); + } else if (strcasecmp(key, LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBSTATE) == 0 && + launch_data_get_type(obj) == LAUNCH_DATA_DICTIONARY) { + launch_data_dict_iterate(obj, semaphoreitem_setup_otherjobs, j); } } Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2007-03-23 20:33:04 UTC (rev 23181) +++ trunk/launchd/src/liblaunch_public.h 2007-03-25 19:52:03 UTC (rev 23182) @@ -106,6 +106,7 @@ #define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit" #define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState" #define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState" +#define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBSTATE "OtherJobState" #define LAUNCH_JOBKEY_CAL_MINUTE "Minute" #define LAUNCH_JOBKEY_CAL_HOUR "Hour" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070325/95f53495/attachment.html From source_changes at macosforge.org Sun Mar 25 13:07:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23183] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070325200729.8981B4F5B86@cvs.opensource.apple.com> Revision: 23183 http://trac.macosforge.org/projects/launchd/changeset/23183 Author: zarzycki@apple.com Date: 2007-03-25 13:07:29 -0700 (Sun, 25 Mar 2007) Log Message: ----------- As long as our hash tables are fixed in size, we should use LISTs intead of SLISTs. Otherwise, the performance of removal becomes expensive under load. 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-03-25 19:52:03 UTC (rev 23182) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-25 20:07:29 UTC (rev 23183) @@ -102,8 +102,8 @@ struct machservice { SLIST_ENTRY(machservice) sle; - SLIST_ENTRY(machservice) name_hash_sle; - SLIST_ENTRY(machservice) port_hash_sle; + LIST_ENTRY(machservice) name_hash_sle; + LIST_ENTRY(machservice) port_hash_sle; job_t job; uint64_t bad_perf_cnt; unsigned int gen_num; @@ -115,7 +115,7 @@ #define PORT_HASH_SIZE 32 #define HASH_PORT(x) (IS_POWER_OF_TWO(PORT_HASH_SIZE) ? (MACH_PORT_INDEX(x) & (PORT_HASH_SIZE - 1)) : (MACH_PORT_INDEX(x) % PORT_HASH_SIZE)) -SLIST_HEAD(, machservice) port_hash[PORT_HASH_SIZE]; +LIST_HEAD(, machservice) port_hash[PORT_HASH_SIZE]; static void machservice_setup(launch_data_t obj, const char *key, void *context); static void machservice_setup_options(launch_data_t obj, const char *key, void *context); @@ -216,8 +216,8 @@ SLIST_ENTRY(jobmgr_s) sle; SLIST_HEAD(, jobmgr_s) submgrs; LIST_HEAD(, job_s) jobs; - SLIST_HEAD(, job_s) active_jobs[ACTIVE_JOB_HASH_SIZE]; - SLIST_HEAD(, machservice) ms_hash[MACHSERVICE_HASH_SIZE]; + LIST_HEAD(, job_s) active_jobs[ACTIVE_JOB_HASH_SIZE]; + LIST_HEAD(, machservice) ms_hash[MACHSERVICE_HASH_SIZE]; mach_port_t jm_port; mach_port_t req_port; jobmgr_t parentmgr; @@ -255,8 +255,8 @@ struct job_s { kq_callback kqjob_callback; LIST_ENTRY(job_s) sle; - SLIST_ENTRY(job_s) pid_hash_sle; - SLIST_ENTRY(job_s) label_hash_sle; + LIST_ENTRY(job_s) pid_hash_sle; + LIST_ENTRY(job_s) label_hash_sle; SLIST_HEAD(, socketgroup) sockets; SLIST_HEAD(, calendarinterval) cal_intervals; SLIST_HEAD(, envitem) global_env; @@ -309,7 +309,7 @@ #define LABEL_HASH_SIZE 53 -SLIST_HEAD(, job_s) label_hash[LABEL_HASH_SIZE]; +LIST_HEAD(, job_s) label_hash[LABEL_HASH_SIZE]; static size_t hash_label(const char *label) __attribute__((pure)); static size_t hash_ms(const char *msstr) __attribute__((pure)); @@ -741,7 +741,7 @@ kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); LIST_REMOVE(j, sle); - SLIST_REMOVE(&label_hash[hash_label(j->label)], j, job_s, label_hash_sle); + LIST_REMOVE(j, label_hash_sle); job_log(j, LOG_DEBUG, "Removed"); @@ -960,7 +960,7 @@ jr->anonymous = true; jr->p = anonpid; /* anonymous process reaping is messy */ - SLIST_INSERT_HEAD(&jm->active_jobs[ACTIVE_JOB_HASH(jr->p)], jr, pid_hash_sle); + 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_log(jr, LOG_DEBUG, "Created anonymously."); } @@ -1047,7 +1047,7 @@ } LIST_INSERT_HEAD(&jm->jobs, j, sle); - SLIST_INSERT_HEAD(&label_hash[hash_label(j->label)], j, label_hash_sle); + LIST_INSERT_HEAD(&label_hash[hash_label(j->label)], j, label_hash_sle); job_log(j, LOG_DEBUG, "Conceived"); @@ -1562,7 +1562,7 @@ { job_t ji; - SLIST_FOREACH(ji, &label_hash[hash_label(label)], label_hash_sle) { + LIST_FOREACH(ji, &label_hash[hash_label(label)], label_hash_sle) { if (strcmp(ji->label, label) == 0) { return ji; } @@ -1586,7 +1586,7 @@ hashp = ACTIVE_JOB_HASH(ldc.pid); - SLIST_FOREACH(ji, &jm->active_jobs[hashp], pid_hash_sle) { + LIST_FOREACH(ji, &jm->active_jobs[hashp], pid_hash_sle) { if (ji->p == ldc.pid) { return ji; } @@ -1638,7 +1638,7 @@ { struct machservice *ms; - SLIST_FOREACH(ms, &port_hash[HASH_PORT(p)], port_hash_sle) { + LIST_FOREACH(ms, &port_hash[HASH_PORT(p)], port_hash_sle) { if (ms->port == p) { return ms->job; } @@ -1730,7 +1730,7 @@ } total_children--; - SLIST_REMOVE(&j->mgr->active_jobs[ACTIVE_JOB_HASH(j->p)], j, job_s, pid_hash_sle); + LIST_REMOVE(j, pid_hash_sle); job_assumes(j, gettimeofday(&tve, NULL) != -1); @@ -1955,7 +1955,7 @@ jobmgr_reap_bulk(jmi, kev); } - SLIST_FOREACH(ji, &jm->active_jobs[ACTIVE_JOB_HASH(kev->ident)], pid_hash_sle) { + LIST_FOREACH(ji, &jm->active_jobs[ACTIVE_JOB_HASH(kev->ident)], pid_hash_sle) { if (ji->p != (pid_t)kev->ident) { continue; } @@ -2111,7 +2111,7 @@ break; default: total_children++; - SLIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, pid_hash_sle); + LIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, pid_hash_sle); if (!j->legacy_mach_job) { job_assumes(j, close(oepair[1]) != -1); @@ -3224,13 +3224,13 @@ void machservice_resetport(job_t j, struct machservice *ms) { - SLIST_REMOVE(&port_hash[HASH_PORT(ms->port)], ms, machservice, port_hash_sle); + LIST_REMOVE(ms, port_hash_sle); job_assumes(j, launchd_mport_close_recv(ms->port) == KERN_SUCCESS); job_assumes(j, launchd_mport_deallocate(ms->port) == KERN_SUCCESS); ms->gen_num++; job_assumes(j, launchd_mport_create_recv(&ms->port) == KERN_SUCCESS); job_assumes(j, launchd_mport_make_send(ms->port) == KERN_SUCCESS); - SLIST_INSERT_HEAD(&port_hash[HASH_PORT(ms->port)], ms, port_hash_sle); + LIST_INSERT_HEAD(&port_hash[HASH_PORT(ms->port)], ms, port_hash_sle); } struct machservice * @@ -3262,8 +3262,8 @@ } SLIST_INSERT_HEAD(&j->machservices, ms, sle); - SLIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(ms->name)], ms, name_hash_sle); - SLIST_INSERT_HEAD(&port_hash[HASH_PORT(ms->port)], ms, port_hash_sle); + LIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(ms->name)], ms, name_hash_sle); + LIST_INSERT_HEAD(&port_hash[HASH_PORT(ms->port)], ms, port_hash_sle); job_log(j, LOG_INFO, "Mach service added: %s", name); @@ -3656,7 +3656,7 @@ */ if (jm == root_jobmgr) { - SLIST_FOREACH_SAFE(ms, &port_hash[HASH_PORT(port)], port_hash_sle, next_ms) { + LIST_FOREACH_SAFE(ms, &port_hash[HASH_PORT(port)], port_hash_sle, next_ms) { if (ms->port == port) { machservice_delete(ms->job, ms); } @@ -3683,7 +3683,7 @@ jobmgr_assumes(jm, !check_parent); } - SLIST_FOREACH(ms, &jm->ms_hash[hash_ms(name)], name_hash_sle) { + LIST_FOREACH(ms, &jm->ms_hash[hash_ms(name)], name_hash_sle) { if ((target_pid && ms->per_pid && ms->job->p == target_pid) || (!target_pid && !ms->per_pid)) { if (strcmp(name, ms->name) == 0) { return ms; @@ -3749,8 +3749,8 @@ job_log(j, LOG_INFO, "Mach service deleted: %s", ms->name); SLIST_REMOVE(&j->machservices, ms, machservice, sle); - SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(ms->name)], ms, machservice, name_hash_sle); - SLIST_REMOVE(&port_hash[HASH_PORT(ms->port)], ms, machservice, port_hash_sle); + LIST_REMOVE(ms, name_hash_sle); + LIST_REMOVE(ms, port_hash_sle); free(ms); } @@ -3834,7 +3834,7 @@ { struct machservice *ms; - SLIST_FOREACH(ms, &port_hash[HASH_PORT(p)], port_hash_sle) { + LIST_FOREACH(ms, &port_hash[HASH_PORT(p)], port_hash_sle) { if (ms->port == p) { break; } @@ -4775,7 +4775,7 @@ struct machservice *msi; SLIST_FOREACH(msi, &j->machservices, sle) { - SLIST_REMOVE(&j->mgr->ms_hash[hash_ms(msi->name)], msi, machservice, name_hash_sle); + LIST_REMOVE(msi, name_hash_sle); } LIST_REMOVE(j, sle); @@ -4783,7 +4783,7 @@ j->mgr = jmi; SLIST_FOREACH(msi, &j->machservices, sle) { - SLIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(msi->name)], msi, name_hash_sle); + LIST_INSERT_HEAD(&j->mgr->ms_hash[hash_ms(msi->name)], msi, name_hash_sle); } } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070325/7ced1341/attachment.html From source_changes at macosforge.org Sun Mar 25 14:28:15 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23184] trunk/launchd/src/launchctl.c Message-ID: <20070325212815.856ED4F5C67@cvs.opensource.apple.com> Revision: 23184 http://trac.macosforge.org/projects/launchd/changeset/23184 Author: zarzycki@apple.com Date: 2007-03-25 14:28:15 -0700 (Sun, 25 Mar 2007) Log Message: ----------- Make bsexec a little smarter. Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-03-25 20:07:29 UTC (rev 23183) +++ trunk/launchd/src/launchctl.c 2007-03-25 21:28:15 UTC (rev 23184) @@ -2621,7 +2621,9 @@ case -1: break; case 0: - setsid(); + if (!_wait) { + setsid(); + } execvp(argv[0], (char *const *)argv); _exit(EXIT_FAILURE); break; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070325/c45158a2/attachment.html From source_changes at macosforge.org Wed Mar 28 17:39:58 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23185] trunk/launchd/src Message-ID: <20070329003958.76C0250A66D@cvs.opensource.apple.com> Revision: 23185 http://trac.macosforge.org/projects/launchd/changeset/23185 Author: zarzycki@apple.com Date: 2007-03-28 17:39:58 -0700 (Wed, 28 Mar 2007) Log Message: ----------- Libsystem should only be cancellable where POSIX specifies (liblaunch) Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2007-03-25 21:28:15 UTC (rev 23184) +++ trunk/launchd/src/Makefile.am 2007-03-29 00:39:58 UTC (rev 23185) @@ -11,9 +11,10 @@ noinst_LIBRARIES = liblaunch.a liblaunch_profile.a +liblaunch_a_CFLAGS = -D__DARWIN_NON_CANCELABLE=1 $(AM_CFLAGS) liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c -liblaunch_profile_a_CFLAGS = -pg $(AM_CFLAGS) +liblaunch_profile_a_CFLAGS = -pg -D__DARWIN_NON_CANCELABLE=1 $(AM_CFLAGS) liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c $(srcdir)/libvproc.c:: protocol_vproc.h @@ -29,9 +30,6 @@ cp liblaunch.a $(DESTDIR)/usr/local/lib/system cp liblaunch.a $(DESTDIR)/usr/local/lib/system/liblaunch_debug.a cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a - dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch.a.dSYM liblaunch.a - dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch_debug.a.dSYM liblaunch.a - dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch_profile.a.dSYM liblaunch_profile.a else Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-03-25 21:28:15 UTC (rev 23184) +++ trunk/launchd/src/Makefile.in 2007-03-29 00:39:58 UTC (rev 23185) @@ -58,10 +58,12 @@ liblaunch_a_LIBADD = am__liblaunch_a_SOURCES_DIST = liblaunch.c libvproc.c libbootstrap.c \ protocol_vprocUser.c __version.c -@LIBS_ONLY_TRUE@am_liblaunch_a_OBJECTS = liblaunch.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ libvproc.$(OBJEXT) libbootstrap.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ protocol_vprocUser.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ __version.$(OBJEXT) +@LIBS_ONLY_TRUE@am_liblaunch_a_OBJECTS = \ +@LIBS_ONLY_TRUE@ liblaunch_a-liblaunch.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ liblaunch_a-libvproc.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ liblaunch_a-libbootstrap.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ liblaunch_a-protocol_vprocUser.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ liblaunch_a-__version.$(OBJEXT) liblaunch_a_OBJECTS = $(am_liblaunch_a_OBJECTS) liblaunch_profile_a_AR = $(AR) $(ARFLAGS) liblaunch_profile_a_LIBADD = @@ -233,8 +235,9 @@ notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a +@LIBS_ONLY_TRUE@liblaunch_a_CFLAGS = -D__DARWIN_NON_CANCELABLE=1 $(AM_CFLAGS) @LIBS_ONLY_TRUE@liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c -@LIBS_ONLY_TRUE@liblaunch_profile_a_CFLAGS = -pg $(AM_CFLAGS) +@LIBS_ONLY_TRUE@liblaunch_profile_a_CFLAGS = -pg -D__DARWIN_NON_CANCELABLE=1 $(AM_CFLAGS) @LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c @LIBS_ONLY_FALSE@sbin_SCRIPTS = service @LIBS_ONLY_FALSE@sysconf_DATA = hostconfig rc.common rc.netboot @@ -425,7 +428,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-IPC.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-StartupItems.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-SystemStarter.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/__version.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchctl-launchctl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-job_replyUser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd.Po@am__quote@ @@ -437,15 +439,16 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-notifyServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-protocol_vprocServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchproxy.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbootstrap.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_a-__version.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_a-libbootstrap.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_a-liblaunch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_a-libvproc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_a-protocol_vprocUser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-__version.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-libbootstrap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-liblaunch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-libvproc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvproc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_vprocUser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wait4path.Po@am__quote@ .c.o: @@ -462,6 +465,76 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +liblaunch_a-liblaunch.o: liblaunch.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-liblaunch.o -MD -MP -MF "$(DEPDIR)/liblaunch_a-liblaunch.Tpo" -c -o liblaunch_a-liblaunch.o `test -f 'liblaunch.c' || echo '$(srcdir)/'`liblaunch.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-liblaunch.Tpo" "$(DEPDIR)/liblaunch_a-liblaunch.Po"; else rm -f "$(DEPDIR)/liblaunch_a-liblaunch.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='liblaunch.c' object='liblaunch_a-liblaunch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-liblaunch.o `test -f 'liblaunch.c' || echo '$(srcdir)/'`liblaunch.c + +liblaunch_a-liblaunch.obj: liblaunch.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-liblaunch.obj -MD -MP -MF "$(DEPDIR)/liblaunch_a-liblaunch.Tpo" -c -o liblaunch_a-liblaunch.obj `if test -f 'liblaunch.c'; then $(CYGPATH_W) 'liblaunch.c'; else $(CYGPATH_W) '$(srcdir)/liblaunch.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-liblaunch.Tpo" "$(DEPDIR)/liblaunch_a-liblaunch.Po"; else rm -f "$(DEPDIR)/liblaunch_a-liblaunch.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='liblaunch.c' object='liblaunch_a-liblaunch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-liblaunch.obj `if test -f 'liblaunch.c'; then $(CYGPATH_W) 'liblaunch.c'; else $(CYGPATH_W) '$(srcdir)/liblaunch.c'; fi` + +liblaunch_a-libvproc.o: libvproc.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-libvproc.o -MD -MP -MF "$(DEPDIR)/liblaunch_a-libvproc.Tpo" -c -o liblaunch_a-libvproc.o `test -f 'libvproc.c' || echo '$(srcdir)/'`libvproc.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-libvproc.Tpo" "$(DEPDIR)/liblaunch_a-libvproc.Po"; else rm -f "$(DEPDIR)/liblaunch_a-libvproc.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libvproc.c' object='liblaunch_a-libvproc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-libvproc.o `test -f 'libvproc.c' || echo '$(srcdir)/'`libvproc.c + +liblaunch_a-libvproc.obj: libvproc.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-libvproc.obj -MD -MP -MF "$(DEPDIR)/liblaunch_a-libvproc.Tpo" -c -o liblaunch_a-libvproc.obj `if test -f 'libvproc.c'; then $(CYGPATH_W) 'libvproc.c'; else $(CYGPATH_W) '$(srcdir)/libvproc.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-libvproc.Tpo" "$(DEPDIR)/liblaunch_a-libvproc.Po"; else rm -f "$(DEPDIR)/liblaunch_a-libvproc.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libvproc.c' object='liblaunch_a-libvproc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-libvproc.obj `if test -f 'libvproc.c'; then $(CYGPATH_W) 'libvproc.c'; else $(CYGPATH_W) '$(srcdir)/libvproc.c'; fi` + +liblaunch_a-libbootstrap.o: libbootstrap.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-libbootstrap.o -MD -MP -MF "$(DEPDIR)/liblaunch_a-libbootstrap.Tpo" -c -o liblaunch_a-libbootstrap.o `test -f 'libbootstrap.c' || echo '$(srcdir)/'`libbootstrap.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-libbootstrap.Tpo" "$(DEPDIR)/liblaunch_a-libbootstrap.Po"; else rm -f "$(DEPDIR)/liblaunch_a-libbootstrap.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libbootstrap.c' object='liblaunch_a-libbootstrap.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-libbootstrap.o `test -f 'libbootstrap.c' || echo '$(srcdir)/'`libbootstrap.c + +liblaunch_a-libbootstrap.obj: libbootstrap.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-libbootstrap.obj -MD -MP -MF "$(DEPDIR)/liblaunch_a-libbootstrap.Tpo" -c -o liblaunch_a-libbootstrap.obj `if test -f 'libbootstrap.c'; then $(CYGPATH_W) 'libbootstrap.c'; else $(CYGPATH_W) '$(srcdir)/libbootstrap.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-libbootstrap.Tpo" "$(DEPDIR)/liblaunch_a-libbootstrap.Po"; else rm -f "$(DEPDIR)/liblaunch_a-libbootstrap.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libbootstrap.c' object='liblaunch_a-libbootstrap.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-libbootstrap.obj `if test -f 'libbootstrap.c'; then $(CYGPATH_W) 'libbootstrap.c'; else $(CYGPATH_W) '$(srcdir)/libbootstrap.c'; fi` + +liblaunch_a-protocol_vprocUser.o: protocol_vprocUser.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-protocol_vprocUser.o -MD -MP -MF "$(DEPDIR)/liblaunch_a-protocol_vprocUser.Tpo" -c -o liblaunch_a-protocol_vprocUser.o `test -f 'protocol_vprocUser.c' || echo '$(srcdir)/'`protocol_vprocUser.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-protocol_vprocUser.Tpo" "$(DEPDIR)/liblaunch_a-protocol_vprocUser.Po"; else rm -f "$(DEPDIR)/liblaunch_a-protocol_vprocUser.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='protocol_vprocUser.c' object='liblaunch_a-protocol_vprocUser.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-protocol_vprocUser.o `test -f 'protocol_vprocUser.c' || echo '$(srcdir)/'`protocol_vprocUser.c + +liblaunch_a-protocol_vprocUser.obj: protocol_vprocUser.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-protocol_vprocUser.obj -MD -MP -MF "$(DEPDIR)/liblaunch_a-protocol_vprocUser.Tpo" -c -o liblaunch_a-protocol_vprocUser.obj `if test -f 'protocol_vprocUser.c'; then $(CYGPATH_W) 'protocol_vprocUser.c'; else $(CYGPATH_W) '$(srcdir)/protocol_vprocUser.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-protocol_vprocUser.Tpo" "$(DEPDIR)/liblaunch_a-protocol_vprocUser.Po"; else rm -f "$(DEPDIR)/liblaunch_a-protocol_vprocUser.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='protocol_vprocUser.c' object='liblaunch_a-protocol_vprocUser.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-protocol_vprocUser.obj `if test -f 'protocol_vprocUser.c'; then $(CYGPATH_W) 'protocol_vprocUser.c'; else $(CYGPATH_W) '$(srcdir)/protocol_vprocUser.c'; fi` + +liblaunch_a-__version.o: __version.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-__version.o -MD -MP -MF "$(DEPDIR)/liblaunch_a-__version.Tpo" -c -o liblaunch_a-__version.o `test -f '__version.c' || echo '$(srcdir)/'`__version.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-__version.Tpo" "$(DEPDIR)/liblaunch_a-__version.Po"; else rm -f "$(DEPDIR)/liblaunch_a-__version.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='__version.c' object='liblaunch_a-__version.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-__version.o `test -f '__version.c' || echo '$(srcdir)/'`__version.c + +liblaunch_a-__version.obj: __version.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -MT liblaunch_a-__version.obj -MD -MP -MF "$(DEPDIR)/liblaunch_a-__version.Tpo" -c -o liblaunch_a-__version.obj `if test -f '__version.c'; then $(CYGPATH_W) '__version.c'; else $(CYGPATH_W) '$(srcdir)/__version.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_a-__version.Tpo" "$(DEPDIR)/liblaunch_a-__version.Po"; else rm -f "$(DEPDIR)/liblaunch_a-__version.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='__version.c' object='liblaunch_a-__version.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_a_CFLAGS) $(CFLAGS) -c -o liblaunch_a-__version.obj `if test -f '__version.c'; then $(CYGPATH_W) '__version.c'; else $(CYGPATH_W) '$(srcdir)/__version.c'; fi` + liblaunch_profile_a-liblaunch.o: liblaunch.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-liblaunch.o -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-liblaunch.Tpo" -c -o liblaunch_profile_a-liblaunch.o `test -f 'liblaunch.c' || echo '$(srcdir)/'`liblaunch.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-liblaunch.Tpo" "$(DEPDIR)/liblaunch_profile_a-liblaunch.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-liblaunch.Tpo"; exit 1; fi @@ -1066,9 +1139,6 @@ @LIBS_ONLY_TRUE@ cp liblaunch.a $(DESTDIR)/usr/local/lib/system @LIBS_ONLY_TRUE@ cp liblaunch.a $(DESTDIR)/usr/local/lib/system/liblaunch_debug.a @LIBS_ONLY_TRUE@ cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a -@LIBS_ONLY_TRUE@ dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch.a.dSYM liblaunch.a -@LIBS_ONLY_TRUE@ dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch_debug.a.dSYM liblaunch.a -@LIBS_ONLY_TRUE@ dsymutil --out=$(DESTDIR)/usr/local/lib/system/liblaunch_profile.a.dSYM liblaunch_profile.a @LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h @LIBS_ONLY_FALSE@launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070328/73989b0b/attachment.html From source_changes at macosforge.org Wed Mar 28 17:43:31 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23186] trunk/launchd/src Message-ID: <20070329004331.9A05850A6BF@cvs.opensource.apple.com> Revision: 23186 http://trac.macosforge.org/projects/launchd/changeset/23186 Author: zarzycki@apple.com Date: 2007-03-28 17:43:31 -0700 (Wed, 28 Mar 2007) Log Message: ----------- Amortize kevent() fetching. I've seen more than 50 events pulled out of the kernel all at once during shutdown with this change. 15-25 events is much more common during shutdown. Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h trunk/launchd/src/launchd_unix_ipc.c trunk/launchd/src/launchd_unix_ipc.h trunk/launchd/src/liblaunch.c trunk/launchd/src/liblaunch_private.h Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-03-29 00:39:58 UTC (rev 23185) +++ trunk/launchd/src/launchd.c 2007-03-29 00:43:31 UTC (rev 23186) @@ -304,13 +304,13 @@ int tmpfd; if (-1 != (tmpfd = dup(fd))) { - launchd_assumes(close(tmpfd) == 0); + launchd_assumes(runtime_close(tmpfd) == 0); } else { if (-1 == (tmpfd = open(path, flags | O_NOCTTY, DEFFILEMODE))) { runtime_syslog(LOG_ERR, "open(\"%s\", ...): %m", path); } else if (tmpfd != fd) { launchd_assumes(dup2(tmpfd, fd) != -1); - launchd_assumes(close(tmpfd) == 0); + launchd_assumes(runtime_close(tmpfd) == 0); } } } @@ -386,7 +386,7 @@ kev_req.kev_class = KEV_NETWORK_CLASS; if (!launchd_assumes(ioctl(pfs, SIOCSKEVFILT, &kev_req) != -1)) { - close(pfs); + runtime_close(pfs); return; } Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-29 00:39:58 UTC (rev 23185) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-29 00:43:31 UTC (rev 23186) @@ -673,11 +673,11 @@ } if (!job_assumes(j, j->forkfd == 0)) { - job_assumes(j, close(j->forkfd) != -1); + job_assumes(j, runtime_close(j->forkfd) != -1); } if (!job_assumes(j, j->log_redirect_fd == 0)) { - job_assumes(j, close(j->log_redirect_fd) != -1); + job_assumes(j, runtime_close(j->log_redirect_fd) != -1); } if (j->j_port) { @@ -1704,12 +1704,12 @@ } if (j->log_redirect_fd && (!j->wait4pipe_eof || j->mgr->shutting_down)) { - job_assumes(j, close(j->log_redirect_fd) != -1); + job_assumes(j, runtime_close(j->log_redirect_fd) != -1); j->log_redirect_fd = 0; } if (j->forkfd) { - job_assumes(j, close(j->forkfd) != -1); + job_assumes(j, runtime_close(j->forkfd) != -1); j->forkfd = 0; } @@ -1849,7 +1849,7 @@ if (rsz == 0) { job_log(j, LOG_DEBUG, "Standard out/error pipe closed"); - job_assumes(j, close(j->log_redirect_fd) != -1); + job_assumes(j, runtime_close(j->log_redirect_fd) != -1); j->log_redirect_fd = 0; job_dispatch(j, false); } else if (job_assumes(j, rsz != -1)) { @@ -2085,25 +2085,25 @@ switch (c = runtime_fork(j->weird_bootstrap ? j->j_port : j->mgr->jm_port)) { case -1: job_log_error(j, LOG_ERR, "fork() failed, will try again in one second"); - job_assumes(j, close(execspair[0]) == 0); - job_assumes(j, close(execspair[1]) == 0); + job_assumes(j, runtime_close(execspair[0]) == 0); + job_assumes(j, runtime_close(execspair[1]) == 0); if (sipc) { - job_assumes(j, close(spair[0]) == 0); - job_assumes(j, close(spair[1]) == 0); + job_assumes(j, runtime_close(spair[0]) == 0); + job_assumes(j, runtime_close(spair[1]) == 0); } break; case 0: if (!j->legacy_mach_job) { job_assumes(j, dup2(oepair[1], STDOUT_FILENO) != -1); job_assumes(j, dup2(oepair[1], STDERR_FILENO) != -1); - job_assumes(j, close(oepair[1]) != -1); + job_assumes(j, runtime_close(oepair[1]) != -1); } - job_assumes(j, close(execspair[0]) == 0); + job_assumes(j, runtime_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 (sipc) { - job_assumes(j, close(spair[0]) == 0); + job_assumes(j, runtime_close(spair[0]) == 0); snprintf(nbuf, sizeof(nbuf), "%d", spair[1]); setenv(LAUNCHD_TRUSTED_FD_ENV, nbuf, 1); } @@ -2114,13 +2114,13 @@ LIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, pid_hash_sle); if (!j->legacy_mach_job) { - job_assumes(j, close(oepair[1]) != -1); + job_assumes(j, runtime_close(oepair[1]) != -1); } j->p = c; j->forkfd = _fd(execspair[0]); - job_assumes(j, close(execspair[1]) == 0); + job_assumes(j, runtime_close(execspair[1]) == 0); if (sipc) { - job_assumes(j, close(spair[1]) == 0); + 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) { @@ -2430,7 +2430,7 @@ } job_assumes(j, dup2(fd, target_fd) != -1); - job_assumes(j, close(fd) == 0); + job_assumes(j, runtime_close(fd) == 0); } int @@ -2745,7 +2745,7 @@ if (invalidation_reason[0]) { job_log(j, LOG_DEBUG, "Path %s: %s", invalidation_reason, si->what); - job_assumes(j, close(si->fd) == 0); + job_assumes(j, runtime_close(si->fd) == 0); si->fd = -1; /* this will get fixed in semaphoreitem_watch() */ } @@ -2873,7 +2873,7 @@ unsigned int i; for (i = 0; i < sg->fd_cnt; i++) - job_assumes(j, close(sg->fds[i]) != -1); + job_assumes(j, runtime_close(sg->fds[i]) != -1); SLIST_REMOVE(&j->sockets, sg, socketgroup, sle); @@ -3148,7 +3148,7 @@ case PATH_MISSING: if ((bool)(stat(si->what, &sb) == 0) == wanted_state) { if (si->fd != -1) { - job_assumes(j, close(si->fd) == 0); + job_assumes(j, runtime_close(si->fd) == 0); si->fd = -1; } job_log(j, LOG_DEBUG, "KeepAlive: The following path %s: %s", wanted_state ? "exists" : "is missing", si->what); @@ -3511,7 +3511,7 @@ /* this unblocks the child and avoids a race * between the above fork() and the kevent_mod() */ job_assumes(j, write(j->forkfd, &c, sizeof(c)) == sizeof(c)); - job_assumes(j, close(j->forkfd) != -1); + job_assumes(j, runtime_close(j->forkfd) != -1); j->forkfd = 0; } @@ -3570,8 +3570,8 @@ int dfd, lfd = strtol(trusted_fd, NULL, 10); if ((dfd = dup(lfd)) >= 0) { - jobmgr_assumes(jmr, close(dfd) != -1); - jobmgr_assumes(jmr, close(lfd) != -1); + jobmgr_assumes(jmr, runtime_close(dfd) != -1); + jobmgr_assumes(jmr, runtime_close(lfd) != -1); } unsetenv(LAUNCHD_TRUSTED_FD_ENV); @@ -3970,11 +3970,11 @@ if (logfile_fd != -1) { job_assumes(j, fcntl(logfile_fd, F_FULLFSYNC, 0) != -1); - job_assumes(j, close(logfile_fd) != -1); + job_assumes(j, runtime_close(logfile_fd) != -1); } if (console_fd != -1) { - job_assumes(j, close(console_fd) != -1); + job_assumes(j, runtime_close(console_fd) != -1); } job_log(j, LOG_DEBUG, "Finished sampling."); @@ -4012,7 +4012,7 @@ SLIST_REMOVE(&j->semaphores, si, semaphoreitem, sle); if (si->fd != -1) { - job_assumes(j, close(si->fd) != -1); + job_assumes(j, runtime_close(si->fd) != -1); } free(si); Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-29 00:39:58 UTC (rev 23185) +++ trunk/launchd/src/launchd_runtime.c 2007-03-29 00:43:31 UTC (rev 23186) @@ -71,12 +71,17 @@ static int mainkq; static int asynckq; +#define BULK_KEV_MAX 100 +static struct kevent *bulk_kev; +static int bulk_kev_i; +static int bulk_kev_cnt; + static pthread_t kqueue_demand_thread; static pthread_t demand_thread; static void *mport_demand_loop(void *arg); static void *kqueue_demand_loop(void *arg); -static void log_kevent_struct(int level, struct kevent *kev); +static void log_kevent_struct(int level, struct kevent *kev, int indx); static void async_callback(void); static kq_callback kqasync_callback = (kq_callback)async_callback; @@ -234,7 +239,7 @@ } void -log_kevent_struct(int level, struct kevent *kev) +log_kevent_struct(int level, struct kevent *kev, int indx) { const char *filter_str; char ident_buf[100]; @@ -394,8 +399,8 @@ break; } - runtime_syslog(level, "KEVENT: udata = %p data = 0x%lx ident = %s filter = %s flags = %s fflags = %s", - kev->udata, kev->data, ident_buf, filter_str, flags_buf, fflags_buf); + runtime_syslog(level, "KEVENT[%d]: udata = %p data = 0x%lx ident = %s filter = %s flags = %s fflags = %s", + indx, kev->udata, kev->data, ident_buf, filter_str, flags_buf, fflags_buf); } kern_return_t @@ -423,7 +428,7 @@ #if 0 if (launchd_assumes(kev.udata != NULL)) { #endif - log_kevent_struct(LOG_DEBUG, &kev); + log_kevent_struct(LOG_DEBUG, &kev, 0); (*((kq_callback *)kev.udata))(kev.udata, &kev); #if 0 } else { @@ -461,19 +466,28 @@ x_handle_kqueue(mach_port_t junk __attribute__((unused)), integer_t fd) { struct timespec ts = { 0, 0 }; - struct kevent kev; - int kevr; + struct kevent kev[BULK_KEV_MAX]; + int i; - launchd_assumes((kevr = kevent(fd, NULL, 0, &kev, 1, &ts)) != -1); + bulk_kev = kev; - if (kevr == 1) { + launchd_assumes((bulk_kev_cnt = kevent(fd, NULL, 0, kev, BULK_KEV_MAX, &ts)) != -1); + + if (bulk_kev_cnt > 0) { #if 0 Dl_info dli; if (launchd_assumes(malloc_size(kev.udata) || dladdr(kev.udata, &dli))) { #endif - log_kevent_struct(LOG_DEBUG, &kev); - (*((kq_callback *)kev.udata))(kev.udata, &kev); + for (i = 0; i < bulk_kev_cnt; i++) { + log_kevent_struct(LOG_DEBUG, &kev[i], i); + } + for (i = 0; i < bulk_kev_cnt; i++) { + bulk_kev_i = i; + if (kev[i].filter) { + (*((kq_callback *)kev[i].udata))(kev[i].udata, &kev[i]); + } + } #if 0 } else { log_kevent_struct(LOG_ERR, &kev); @@ -481,6 +495,8 @@ #endif } + bulk_kev = NULL; + return 0; } @@ -683,7 +699,7 @@ struct kevent kev; if (launchd_assumes(kevent(asynckq, NULL, 0, &kev, 1, &timeout) == 1)) { - log_kevent_struct(LOG_DEBUG, &kev); + log_kevent_struct(LOG_DEBUG, &kev, 0); (*((kq_callback *)kev.udata))(kev.udata, &kev); } } @@ -925,6 +941,28 @@ } } +int +runtime_close(int fd) +{ + int i; + + if (bulk_kev) for (i = bulk_kev_i + 1; i < bulk_kev_cnt; i++) { + switch (bulk_kev[i].filter) { + case EVFILT_VNODE: + case EVFILT_WRITE: + case EVFILT_READ: + if ((int)bulk_kev[i].ident == fd) { + runtime_syslog(LOG_DEBUG, "Skipping kevent index: %d", i); + bulk_kev[i].filter = 0; + } + default: + break; + } + } + + return close(fd); +} + static FILE *ourlogfile; void Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-03-29 00:39:58 UTC (rev 23185) +++ trunk/launchd/src/launchd_runtime.h 2007-03-29 00:43:31 UTC (rev 23186) @@ -59,6 +59,8 @@ void launchd_runtime_init(void); void launchd_runtime(void) __attribute__((noreturn)); +int runtime_close(int fd); + void runtime_force_on_demand(bool); void runtime_set_timeout(timeout_callback to_cb, mach_msg_timeout_t to); kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size); Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2007-03-29 00:39:58 UTC (rev 23185) +++ trunk/launchd/src/launchd_unix_ipc.c 2007-03-29 00:43:31 UTC (rev 23186) @@ -47,15 +47,15 @@ #include #include -#include "launch.h" -#include "launch_priv.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" #include "launchd.h" #include "launchd_runtime.h" #include "launchd_core_logic.h" extern char **environ; -static SLIST_HEAD(, conncb) connections = { NULL }; +static LIST_HEAD(, conncb) connections; static launch_data_t adjust_rlimits(launch_data_t in); @@ -171,7 +171,7 @@ out_bad: if (!ipc_inited && fd != -1) { - launchd_assumes(close(fd) == 0); + launchd_assumes(runtime_close(fd) == 0); } } @@ -185,7 +185,7 @@ c->kqconn_callback = ipc_callback; c->conn = launchd_fdopen(fd); c->j = j; - SLIST_INSERT_HEAD(&connections, c, sle); + LIST_INSERT_HEAD(&connections, c, sle); kevent_mod(fd, EVFILT_READ, EV_ADD, 0, 0, &c->kqconn_callback); } @@ -242,7 +242,7 @@ { struct conncb *ci, *cin; - SLIST_FOREACH_SAFE(ci, &connections, sle, cin) { + LIST_FOREACH_SAFE(ci, &connections, sle, cin) { if (ci->j == j) { ipc_close(ci); } @@ -264,7 +264,7 @@ break; case LAUNCH_DATA_FD: if (launch_data_get_fd(o) != -1) { - launchd_assumes(close(launch_data_get_fd(o)) == 0); + launchd_assumes(runtime_close(launch_data_get_fd(o)) == 0); } break; default: @@ -457,8 +457,8 @@ { batch_job_enable(true, c); - SLIST_REMOVE(&connections, c, conncb, sle); - launchd_close(c->conn); + LIST_REMOVE(c, sle); + launchd_close(c->conn, runtime_close); free(c); } Modified: trunk/launchd/src/launchd_unix_ipc.h =================================================================== --- trunk/launchd/src/launchd_unix_ipc.h 2007-03-29 00:39:58 UTC (rev 23185) +++ trunk/launchd/src/launchd_unix_ipc.h 2007-03-29 00:43:31 UTC (rev 23186) @@ -24,11 +24,11 @@ #include "launchd_runtime.h" #include "launchd_core_logic.h" -#include "launch_priv.h" +#include "liblaunch_private.h" struct conncb { kq_callback kqconn_callback; - SLIST_ENTRY(conncb) sle; + LIST_ENTRY(conncb) sle; launch_t conn; job_t j; int disabled_batch:1, futureflags:31; Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2007-03-29 00:39:58 UTC (rev 23185) +++ trunk/launchd/src/liblaunch.c 2007-03-29 00:43:31 UTC (rev 23186) @@ -210,7 +210,7 @@ return; out_bad: if (_lc->l) - launchd_close(_lc->l); + launchd_close(_lc->l, close); else if (lfd != -1) close(lfd); if (_lc) @@ -560,7 +560,7 @@ } void -launchd_close(launch_t lh) +launchd_close(launch_t lh, typeof(close) closefunc) { if (lh->sendbuf) free(lh->sendbuf); @@ -570,7 +570,7 @@ free(lh->recvbuf); if (lh->recvfds) free(lh->recvfds); - close(lh->fd); + closefunc(lh->fd); free(lh); } Modified: trunk/launchd/src/liblaunch_private.h =================================================================== --- trunk/launchd/src/liblaunch_private.h 2007-03-29 00:39:58 UTC (rev 23185) +++ trunk/launchd/src/liblaunch_private.h 2007-03-29 00:43:31 UTC (rev 23186) @@ -23,6 +23,7 @@ #include #include #include +#include #pragma GCC visibility push(default) @@ -62,7 +63,7 @@ launch_t launchd_fdopen(int); int launchd_getfd(launch_t); -void launchd_close(launch_t); +void launchd_close(launch_t, typeof(close) closefunc); launch_data_t launch_data_new_errno(int); bool launch_data_set_errno(launch_data_t, int); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070328/994c62cf/attachment.html From source_changes at macosforge.org Wed Mar 28 18:07:47 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23187] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070329010747.A652650A7EB@cvs.opensource.apple.com> Revision: 23187 http://trac.macosforge.org/projects/launchd/changeset/23187 Author: zarzycki@apple.com Date: 2007-03-28 18:07:47 -0700 (Wed, 28 Mar 2007) Log Message: ----------- Better logging. 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-03-29 00:43:31 UTC (rev 23186) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-29 01:07:47 UTC (rev 23187) @@ -945,7 +945,7 @@ { int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, anonpid }; char newlabel[1000]; - struct kinfo_proc kp; + struct kinfo_proc kp, ppid_kp; size_t len = sizeof(kp); job_t jr = NULL; @@ -953,6 +953,12 @@ return NULL; } + mib[3] = kp.kp_eproc.e_ppid; + + if (!jobmgr_assumes(jm, sysctl(mib, 4, &ppid_kp, &len, NULL, 0) != -1)) { + return NULL; + } + snprintf(newlabel, sizeof(newlabel), "anonymous-%u.%s", anonpid, kp.kp_proc.p_comm); if (jobmgr_assumes(jm, (jr = job_new(jm, newlabel, kp.kp_proc.p_comm, NULL)) != NULL)) { @@ -962,7 +968,7 @@ /* 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_log(jr, LOG_DEBUG, "Created anonymously."); + job_log(jr, LOG_DEBUG, "Created anonymously by PPID %u: %s", kp.kp_eproc.e_ppid, ppid_kp.kp_proc.p_comm); } return jr; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070328/471c47c0/attachment.html From source_changes at macosforge.org Wed Mar 28 18:27:08 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23188] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070329012708.5F8DD50A929@cvs.opensource.apple.com> Revision: 23188 http://trac.macosforge.org/projects/launchd/changeset/23188 Author: zarzycki@apple.com Date: 2007-03-28 18:27:08 -0700 (Wed, 28 Mar 2007) Log Message: ----------- Let's make NOTE_EXEC smarter for anonymous jobs. 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-03-29 01:07:47 UTC (rev 23187) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-29 01:27:08 UTC (rev 23188) @@ -981,7 +981,7 @@ char auto_label[1000]; char *bn = NULL; char *co; - int i, cc = 0; + int minlabel_len, i, cc = 0; job_t j; launchd_assert(offsetof(struct job_s, kqjob_callback) == 0); @@ -1002,8 +1002,14 @@ label = auto_label; } - j = calloc(1, sizeof(struct job_s) + strlen(label) + 1); + /* This is so we can do gross things later. See NOTE_EXEC for anonymous jobs */ + minlabel_len = strlen(label); + if (minlabel_len < MAXCOMLEN) { + minlabel_len = MAXCOMLEN; + } + j = calloc(1, sizeof(struct job_s) + minlabel_len + 1); + if (!jobmgr_assumes(jm, j != NULL)) { return NULL; } @@ -1889,11 +1895,21 @@ void job_callback_proc(job_t j, int flags, int fflags) { - if (fflags & NOTE_EXEC) { - job_log(j, LOG_DEBUG, "Called execve()"); - if (j->anonymous) { - flags |= EV_EOF|EV_ONESHOT; - fflags |= NOTE_EXIT; + if ((fflags & NOTE_EXEC) && j->anonymous) { + int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, j->p }; + struct kinfo_proc kp; + size_t len = sizeof(kp); + + if (job_assumes(j, sysctl(mib, 4, &kp, &len, NULL, 0) != -1)) { + char newlabel[1000]; + + snprintf(newlabel, sizeof(newlabel), "anonymous-%u.%s", j->p, kp.kp_proc.p_comm); + + job_log(j, LOG_DEBUG, "Program changed. Updating the label to: %s", newlabel); + + LIST_REMOVE(j, label_hash_sle); + strcpy((char *)j->label, newlabel); + LIST_INSERT_HEAD(&label_hash[hash_label(j->label)], j, label_hash_sle); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070328/e43fc1ea/attachment.html From source_changes at macosforge.org Wed Mar 28 18:29:52 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23189] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070329012952.E47D750A94E@cvs.opensource.apple.com> Revision: 23189 http://trac.macosforge.org/projects/launchd/changeset/23189 Author: zarzycki@apple.com Date: 2007-03-28 18:29:52 -0700 (Wed, 28 Mar 2007) Log Message: ----------- This just isn't a big deal any more. 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-03-29 01:27:08 UTC (rev 23188) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-29 01:29:52 UTC (rev 23189) @@ -1794,10 +1794,6 @@ } } - if (!j->checkedin && (!SLIST_EMPTY(&j->sockets) || !SLIST_EMPTY(&j->machservices))) { - job_log(j, LOG_WARNING, "Failed to check-in!"); - } - j->last_exit_status = status; j->sent_sigkill = false; j->p = 0; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070328/6bd01294/attachment.html From source_changes at macosforge.org Thu Mar 29 14:38:00 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23190] trunk/launchd/src Message-ID: <20070329213800.8A75950BDE4@cvs.opensource.apple.com> Revision: 23190 http://trac.macosforge.org/projects/launchd/changeset/23190 Author: zarzycki@apple.com Date: 2007-03-29 14:38:00 -0700 (Thu, 29 Mar 2007) Log Message: ----------- Avoid floating point. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-03-29 01:29:52 UTC (rev 23189) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-29 21:38:00 UTC (rev 23190) @@ -1753,13 +1753,10 @@ } if (j->sent_sigterm_time.tv_sec) { - double delta; - timersub(&tve, &j->sent_sigterm_time, &tvd); - delta = (double)tvd.tv_sec + (double)tvd.tv_usec / (double)1000000; - - job_log(j, LOG_INFO, "Exited %f seconds after SIGTERM was sent", delta); + job_log(j, LOG_INFO, "Exited %ld.%06d seconds after %s was sent", + tvd.tv_sec, tvd.tv_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM)); } #if DO_RUSAGE_SUMMATION Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-29 01:29:52 UTC (rev 23189) +++ trunk/launchd/src/launchd_runtime.c 2007-03-29 21:38:00 UTC (rev 23190) @@ -1001,13 +1001,13 @@ runtime_vsyslog(int priority, const char *message, va_list args) { static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER; - static struct timeval shutdown_start = { 0, 0 }; + static struct timeval shutdown_start; + static struct timeval prev_msg; static int apple_internal_logging = 1; - struct timeval tvnow, tvd; + struct timeval tvnow, tvd_total, tvd_msg_delta; struct stat sb; int saved_errno = errno; char newmsg[10000]; - double float_time; size_t i, j; if (apple_internal_logging == 1) { @@ -1052,11 +1052,15 @@ return; } - timersub(&tvnow, &shutdown_start, &tvd); + timersub(&tvnow, &shutdown_start, &tvd_total); + timersub(&tvnow, &prev_msg, &tvd_msg_delta); - float_time = (double)tvd.tv_sec + (double)tvd.tv_usec / (double)1000000; - snprintf(newmsg, sizeof(newmsg), "%f\t", float_time); + prev_msg = tvnow; + snprintf(newmsg, sizeof(newmsg), "%3ld.%06d\t%ld.%06d\t", + tvd_total.tv_sec, tvd_total.tv_usec, + tvd_msg_delta.tv_sec, tvd_msg_delta.tv_usec); + for (i = 0, j = strlen(newmsg); message[i];) { if (message[i] == '%' && message[i + 1] == 'm') { char *errs = strerror(saved_errno); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070329/d6fc28ff/attachment.html From source_changes at macosforge.org Thu Mar 29 15:22:28 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23191] trunk/launchd/src/launchd_runtime.c Message-ID: <20070329222228.D34B750BE5F@cvs.opensource.apple.com> Revision: 23191 http://trac.macosforge.org/projects/launchd/changeset/23191 Author: zarzycki@apple.com Date: 2007-03-29 15:22:28 -0700 (Thu, 29 Mar 2007) Log Message: ----------- Make the first log line delta zero. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-03-29 21:38:00 UTC (rev 23190) +++ trunk/launchd/src/launchd_runtime.c 2007-03-29 22:22:28 UTC (rev 23191) @@ -1004,7 +1004,7 @@ static struct timeval shutdown_start; static struct timeval prev_msg; static int apple_internal_logging = 1; - struct timeval tvnow, tvd_total, tvd_msg_delta; + struct timeval tvnow, tvd_total, tvd_msg_delta = { 0, 0 }; struct stat sb; int saved_errno = errno; char newmsg[10000]; @@ -1053,8 +1053,11 @@ } timersub(&tvnow, &shutdown_start, &tvd_total); - timersub(&tvnow, &prev_msg, &tvd_msg_delta); + if (prev_msg.tv_sec != 0) { + timersub(&tvnow, &prev_msg, &tvd_msg_delta); + } + prev_msg = tvnow; snprintf(newmsg, sizeof(newmsg), "%3ld.%06d\t%ld.%06d\t", -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070329/55c05642/attachment.html From source_changes at macosforge.org Thu Mar 29 15:39:26 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23192] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070329223926.1F4B550C0BE@cvs.opensource.apple.com> Revision: 23192 http://trac.macosforge.org/projects/launchd/changeset/23192 Author: zarzycki@apple.com Date: 2007-03-29 15:39:26 -0700 (Thu, 29 Mar 2007) Log Message: ----------- 9A402: Hundreds of launchd notices and errors being logged on shutdown 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-03-29 22:22:28 UTC (rev 23191) +++ trunk/launchd/src/launchd_core_logic.c 2007-03-29 22:39:26 UTC (rev 23192) @@ -947,6 +947,7 @@ char newlabel[1000]; struct kinfo_proc kp, ppid_kp; size_t len = sizeof(kp); + bool shutdown_state; job_t jr = NULL; if (!jobmgr_assumes(jm, sysctl(mib, 4, &kp, &len, NULL, 0) != -1)) { @@ -961,6 +962,11 @@ snprintf(newlabel, sizeof(newlabel), "anonymous-%u.%s", anonpid, kp.kp_proc.p_comm); + /* A total hack: Normally, job_new() returns an error during shutdown, but anonymous jobs are special. */ + if ((shutdown_state = jm->shutting_down)) { + jm->shutting_down = false; + } + if (jobmgr_assumes(jm, (jr = job_new(jm, newlabel, kp.kp_proc.p_comm, NULL)) != NULL)) { total_children++; jr->anonymous = true; @@ -968,9 +974,17 @@ /* 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); + if (shutdown_state) { + 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); + } job_log(jr, LOG_DEBUG, "Created anonymously by PPID %u: %s", kp.kp_eproc.e_ppid, ppid_kp.kp_proc.p_comm); } + if (shutdown_state) { + jm->shutting_down = true; + } + return jr; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070329/73d427bd/attachment.html From source_changes at macosforge.org Thu Mar 29 19:54:51 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23193] trunk/launchd/src/SystemStarter.c Message-ID: <20070330025451.B191F50C59F@cvs.opensource.apple.com> Revision: 23193 http://trac.macosforge.org/projects/launchd/changeset/23193 Author: zarzycki@apple.com Date: 2007-03-29 19:54:51 -0700 (Thu, 29 Mar 2007) Log Message: ----------- leopard: regression: rc.local not supported Modified Paths: -------------- trunk/launchd/src/SystemStarter.c Modified: trunk/launchd/src/SystemStarter.c =================================================================== --- trunk/launchd/src/SystemStarter.c 2007-03-29 22:39:26 UTC (rev 23192) +++ trunk/launchd/src/SystemStarter.c 2007-03-30 02:54:51 UTC (rev 23193) @@ -148,7 +148,7 @@ system_starter(kActionStart, NULL); if (stat("/etc/rc.local", &sb) != -1) { - const char *rc_local_cmd[] = { "_PATH_BSHELL", "/etc/rc.local", NULL }; + const char *rc_local_cmd[] = { _PATH_BSHELL, "/etc/rc.local", NULL }; fwexec(rc_local_cmd, true); } @@ -164,7 +164,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 }; + const char *rc_shutdown_local_cmd[] = { _PATH_BSHELL, "/etc/rc.shutdown.local", NULL }; fwexec(rc_shutdown_local_cmd, true); } @@ -409,7 +409,6 @@ case -1: return -1; case 0: - setsid(); execvp(argv[0], (char *const *)argv); _exit(EXIT_FAILURE); break; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070329/63df32e3/attachment.html From source_changes at macosforge.org Thu Mar 29 20:11:46 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:45 2007 Subject: [launchd-changes] [23194] trunk/launchd/src/SystemStarter.c Message-ID: <20070330031146.935CE50C5BF@cvs.opensource.apple.com> Revision: 23194 http://trac.macosforge.org/projects/launchd/changeset/23194 Author: zarzycki@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