<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[23459] branches/SULeopard/launchd/src</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/launchd/changeset/23459">23459</a></dd>
<dt>Author</dt> <dd>zarzycki@apple.com</dd>
<dt>Date</dt> <dd>2007-12-07 13:15:23 -0800 (Fri, 07 Dec 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre><rdar://problem/5502233> SULeoCeto: ReportCrash can deadlock against itself if it crashes prior to main()</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesSULeopardlaunchdsrcMakefileam">branches/SULeopard/launchd/src/Makefile.am</a></li>
<li><a href="#branchesSULeopardlaunchdsrcMakefilein">branches/SULeopard/launchd/src/Makefile.in</a></li>
<li><a href="#branchesSULeopardlaunchdsrclaunchd_core_logicc">branches/SULeopard/launchd/src/launchd_core_logic.c</a></li>
<li><a href="#branchesSULeopardlaunchdsrclaunchd_runtimec">branches/SULeopard/launchd/src/launchd_runtime.c</a></li>
<li><a href="#branchesSULeopardlaunchdsrclaunchd_runtimeh">branches/SULeopard/launchd/src/launchd_runtime.h</a></li>
<li><a href="#branchesSULeopardlaunchdsrcliblaunch_privateh">branches/SULeopard/launchd/src/liblaunch_private.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesSULeopardlaunchdsrcMakefileam"></a>
<div class="modfile"><h4>Modified: branches/SULeopard/launchd/src/Makefile.am (23458 => 23459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/SULeopard/launchd/src/Makefile.am        2007-12-07 21:06:19 UTC (rev 23458)
+++ branches/SULeopard/launchd/src/Makefile.am        2007-12-07 21:15:23 UTC (rev 23459)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx">
</span><span class="cx"> CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h                \
</span><span class="cx">          launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c        \
</span><del>-         notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c
</del><ins>+         notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h
</ins><span class="cx">
</span><span class="cx"> protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h: $(srcdir)/protocol_job.defs
</span><span class="cx">         mig $(MIGFLAGS) -sheader protocol_vprocServer.h $(srcdir)/protocol_job.defs
</span><span class="lines">@@ -48,9 +48,9 @@
</span><span class="cx">
</span><span class="cx"> launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter
</span><span class="cx"> launchd_LDFLAGS = -lbsm
</span><del>-launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c
</del><ins>+launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c mach_excServer.c
</ins><span class="cx">
</span><del>-launchd_runtime.c:: notifyServer.h launchd_internal.h
</del><ins>+launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h
</ins><span class="cx"> launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h
</span><span class="cx">
</span><span class="cx"> launchproxy_LDFLAGS = -weak_framework Security
</span><span class="lines">@@ -58,6 +58,9 @@
</span><span class="cx"> notifyServer.c notifyServer.h: /usr/include/mach/notify.defs
</span><span class="cx">         mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs
</span><span class="cx">
</span><ins>+mach_excServer.c mach_excServer.h: /usr/include/mach/mach_exc.defs
+        mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader mach_excServer.h /usr/include/mach/mach_exc.defs
+
</ins><span class="cx"> job_replyUser.c job_reply.h: $(srcdir)/protocol_job_reply.defs
</span><span class="cx">         mig $(MIGFLAGS) -sheader /dev/null -server /dev/null $(srcdir)/protocol_job_reply.defs
</span><span class="cx">
</span></span></pre></div>
<a id="branchesSULeopardlaunchdsrcMakefilein"></a>
<div class="modfile"><h4>Modified: branches/SULeopard/launchd/src/Makefile.in (23458 => 23459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/SULeopard/launchd/src/Makefile.in        2007-12-07 21:06:19 UTC (rev 23458)
+++ branches/SULeopard/launchd/src/Makefile.in        2007-12-07 21:15:23 UTC (rev 23459)
</span><span class="lines">@@ -96,7 +96,8 @@
</span><span class="cx"> am__launchd_SOURCES_DIST = launchd.c launchd_core_logic.c \
</span><span class="cx">         launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c \
</span><span class="cx">         launchd_internalUser.c launchd_internalServer.c \
</span><del>-        job_replyUser.c launchd_runtime.c launchd_runtime_kill.c
</del><ins>+        job_replyUser.c launchd_runtime.c launchd_runtime_kill.c \
+        mach_excServer.c
</ins><span class="cx"> @LIBS_ONLY_FALSE@am_launchd_OBJECTS = launchd-launchd.$(OBJEXT) \
</span><span class="cx"> @LIBS_ONLY_FALSE@        launchd-launchd_core_logic.$(OBJEXT) \
</span><span class="cx"> @LIBS_ONLY_FALSE@        launchd-launchd_unix_ipc.$(OBJEXT) \
</span><span class="lines">@@ -106,7 +107,8 @@
</span><span class="cx"> @LIBS_ONLY_FALSE@        launchd-launchd_internalServer.$(OBJEXT) \
</span><span class="cx"> @LIBS_ONLY_FALSE@        launchd-job_replyUser.$(OBJEXT) \
</span><span class="cx"> @LIBS_ONLY_FALSE@        launchd-launchd_runtime.$(OBJEXT) \
</span><del>-@LIBS_ONLY_FALSE@        launchd-launchd_runtime_kill.$(OBJEXT)
</del><ins>+@LIBS_ONLY_FALSE@        launchd-launchd_runtime_kill.$(OBJEXT) \
+@LIBS_ONLY_FALSE@        launchd-mach_excServer.$(OBJEXT)
</ins><span class="cx"> launchd_OBJECTS = $(am_launchd_OBJECTS)
</span><span class="cx"> launchd_LDADD = $(LDADD)
</span><span class="cx"> launchd_LINK = $(CCLD) $(launchd_CFLAGS) $(CFLAGS) $(launchd_LDFLAGS) \
</span><span class="lines">@@ -238,7 +240,7 @@
</span><span class="cx"> 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__
</span><span class="cx"> CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h                \
</span><span class="cx">          launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c        \
</span><del>-         notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c
</del><ins>+         notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h
</ins><span class="cx">
</span><span class="cx"> @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a
</span><span class="cx"> @LIBS_ONLY_TRUE@liblaunch_a_CFLAGS = -D__DARWIN_NON_CANCELABLE=1 $(AM_CFLAGS)
</span><span class="lines">@@ -253,7 +255,7 @@
</span><span class="cx"> @LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c
</span><span class="cx"> @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter
</span><span class="cx"> @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm
</span><del>-@LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c
</del><ins>+@LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c mach_excServer.c
</ins><span class="cx"> @LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security
</span><span class="cx"> @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1
</span><span class="cx"> @LIBS_ONLY_FALSE@man5_MANS = launchd.plist.5 launchd.conf.5
</span><span class="lines">@@ -423,6 +425,7 @@
</span><span class="cx"> @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_runtime.Po@am__quote@
</span><span class="cx"> @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_runtime_kill.Po@am__quote@
</span><span class="cx"> @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_unix_ipc.Po@am__quote@
</span><ins>+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-mach_excServer.Po@am__quote@
</ins><span class="cx"> @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-notifyServer.Po@am__quote@
</span><span class="cx"> @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-protocol_vprocServer.Po@am__quote@
</span><span class="cx"> @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchproxy.Po@am__quote@
</span><span class="lines">@@ -787,6 +790,20 @@
</span><span class="cx"> @AMDEP_TRUE@@am__fastdepCC_FALSE@        source='launchd_runtime_kill.c' object='launchd-launchd_runtime_kill.obj' libtool=no @AMDEPBACKSLASH@
</span><span class="cx"> @AMDEP_TRUE@@am__fastdepCC_FALSE@        DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
</span><span class="cx"> @am__fastdepCC_FALSE@        $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-launchd_runtime_kill.obj `if test -f 'launchd_runtime_kill.c'; then $(CYGPATH_W) 'launchd_runtime_kill.c'; else $(CYGPATH_W) '$(srcdir)/launchd_runtime_kill.c'; fi`
</span><ins>+
+launchd-mach_excServer.o: mach_excServer.c
+@am__fastdepCC_TRUE@        $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-mach_excServer.o -MD -MP -MF $(DEPDIR)/launchd-mach_excServer.Tpo -c -o launchd-mach_excServer.o `test -f 'mach_excServer.c' || echo '$(srcdir)/'`mach_excServer.c
+@am__fastdepCC_TRUE@        mv -f $(DEPDIR)/launchd-mach_excServer.Tpo $(DEPDIR)/launchd-mach_excServer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@        source='mach_excServer.c' object='launchd-mach_excServer.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) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-mach_excServer.o `test -f 'mach_excServer.c' || echo '$(srcdir)/'`mach_excServer.c
+
+launchd-mach_excServer.obj: mach_excServer.c
+@am__fastdepCC_TRUE@        $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-mach_excServer.obj -MD -MP -MF $(DEPDIR)/launchd-mach_excServer.Tpo -c -o launchd-mach_excServer.obj `if test -f 'mach_excServer.c'; then $(CYGPATH_W) 'mach_excServer.c'; else $(CYGPATH_W) '$(srcdir)/mach_excServer.c'; fi`
+@am__fastdepCC_TRUE@        mv -f $(DEPDIR)/launchd-mach_excServer.Tpo $(DEPDIR)/launchd-mach_excServer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@        source='mach_excServer.c' object='launchd-mach_excServer.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) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-mach_excServer.obj `if test -f 'mach_excServer.c'; then $(CYGPATH_W) 'mach_excServer.c'; else $(CYGPATH_W) '$(srcdir)/mach_excServer.c'; fi`
</ins><span class="cx"> install-man1: $(man1_MANS) $(man_MANS)
</span><span class="cx">         @$(NORMAL_INSTALL)
</span><span class="cx">         test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
</span><span class="lines">@@ -1148,12 +1165,15 @@
</span><span class="cx"> @LIBS_ONLY_TRUE@        cp liblaunch.a $(DESTDIR)/usr/local/lib/system/liblaunch_debug.a
</span><span class="cx"> @LIBS_ONLY_TRUE@        cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a
</span><span class="cx">
</span><del>-@LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h
</del><ins>+@LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h
</ins><span class="cx"> @LIBS_ONLY_FALSE@launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h
</span><span class="cx">
</span><span class="cx"> @LIBS_ONLY_FALSE@notifyServer.c notifyServer.h: /usr/include/mach/notify.defs
</span><span class="cx"> @LIBS_ONLY_FALSE@        mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs
</span><span class="cx">
</span><ins>+@LIBS_ONLY_FALSE@mach_excServer.c mach_excServer.h: /usr/include/mach/mach_exc.defs
+@LIBS_ONLY_FALSE@        mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader mach_excServer.h /usr/include/mach/mach_exc.defs
+
</ins><span class="cx"> @LIBS_ONLY_FALSE@job_replyUser.c job_reply.h: $(srcdir)/protocol_job_reply.defs
</span><span class="cx"> @LIBS_ONLY_FALSE@        mig $(MIGFLAGS) -sheader /dev/null -server /dev/null $(srcdir)/protocol_job_reply.defs
</span><span class="cx">
</span></span></pre></div>
<a id="branchesSULeopardlaunchdsrclaunchd_core_logicc"></a>
<div class="modfile"><h4>Modified: branches/SULeopard/launchd/src/launchd_core_logic.c (23458 => 23459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/SULeopard/launchd/src/launchd_core_logic.c        2007-12-07 21:06:19 UTC (rev 23458)
+++ branches/SULeopard/launchd/src/launchd_core_logic.c        2007-12-07 21:15:23 UTC (rev 23459)
</span><span class="lines">@@ -333,6 +333,7 @@
</span><span class="cx">         char *groupname;
</span><span class="cx">         char *stdoutpath;
</span><span class="cx">         char *stderrpath;
</span><ins>+        char *alt_exc_handler;
</ins><span class="cx">         struct machservice *lastlookup;
</span><span class="cx">         unsigned int lastlookup_gennum;
</span><span class="cx">         char *seatbelt_profile;
</span><span class="lines">@@ -360,7 +361,7 @@
</span><span class="cx">                  currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1,
</span><span class="cx">                  wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1,
</span><span class="cx">                  per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1,
</span><del>-                 poll_for_vfs_changes:1;
</del><ins>+                 poll_for_vfs_changes:1, internal_exc_handler:1;
</ins><span class="cx">         const char label[0];
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -861,6 +862,9 @@
</span><span class="cx">         if (j->stderrpath) {
</span><span class="cx">                 free(j->stderrpath);
</span><span class="cx">         }
</span><ins>+        if (j->alt_exc_handler) {
+                free(j->alt_exc_handler);
+        }
</ins><span class="cx">         if (j->seatbelt_profile) {
</span><span class="cx">                 free(j->seatbelt_profile);
</span><span class="cx">         }
</span><span class="lines">@@ -1323,6 +1327,13 @@
</span><span class="cx">                         found_key = true;
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><ins>+        case 'm':
+        case 'M':
+                if (strcasecmp(key, LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER) == 0) {
+                        j->internal_exc_handler = value;
+                        found_key = true;
+                }
+                break;
</ins><span class="cx">         case 'i':
</span><span class="cx">         case 'I':
</span><span class="cx">                 if (strcasecmp(key, LAUNCH_JOBKEY_INITGROUPS) == 0) {
</span><span class="lines">@@ -1376,6 +1387,12 @@
</span><span class="cx">         char **where2put = NULL;
</span><span class="cx">
</span><span class="cx">         switch (key[0]) {
</span><ins>+        case 'm':
+        case 'M':
+                if (strcasecmp(key, LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER) == 0) {
+                        where2put = &j->alt_exc_handler;
+                }
+                break;
</ins><span class="cx">         case 'p':
</span><span class="cx">         case 'P':
</span><span class="cx">                 if (strcasecmp(key, LAUNCH_JOBKEY_PROGRAM) == 0) {
</span><span class="lines">@@ -4002,9 +4019,20 @@
</span><span class="cx"> void
</span><span class="cx"> job_setup_exception_port(job_t j, task_t target_task)
</span><span class="cx"> {
</span><ins>+        struct machservice *ms;
</ins><span class="cx">         thread_state_flavor_t f = 0;
</span><ins>+        mach_port_t exc_port = the_exception_server;
</ins><span class="cx">
</span><del>-        if (!the_exception_server) {
</del><ins>+        if (j->alt_exc_handler) {
+                ms = jobmgr_lookup_service(j->mgr, j->alt_exc_handler, true, 0);
+                if (ms) {
+                        exc_port = machservice_port(ms);
+                } else {
+                        job_log(j, LOG_WARNING, "Falling back to default Mach exception handler. Could not find: %s", j->alt_exc_handler);
+                }
+        } else if (j->internal_exc_handler) {
+                exc_port = runtime_get_kernel_port();
+        } else if (!exc_port) {
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -4015,9 +4043,9 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         if (target_task) {
</span><del>-                job_assumes(j, task_set_exception_ports(target_task, EXC_MASK_CRASH, the_exception_server,
</del><ins>+                job_assumes(j, task_set_exception_ports(target_task, EXC_MASK_CRASH, exc_port,
</ins><span class="cx">                                         EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS);
</span><del>-        } else if (getpid() == 1) {
</del><ins>+        } else if (getpid() == 1 && the_exception_server) {
</ins><span class="cx">                 mach_port_t mhp = mach_host_self();
</span><span class="cx">                 job_assumes(j, host_set_exception_ports(mhp, EXC_MASK_CRASH, the_exception_server,
</span><span class="cx">                                         EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS);
</span></span></pre></div>
<a id="branchesSULeopardlaunchdsrclaunchd_runtimec"></a>
<div class="modfile"><h4>Modified: branches/SULeopard/launchd/src/launchd_runtime.c (23458 => 23459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/SULeopard/launchd/src/launchd_runtime.c        2007-12-07 21:06:19 UTC (rev 23458)
+++ branches/SULeopard/launchd/src/launchd_runtime.c        2007-12-07 21:15:23 UTC (rev 23459)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> #include "launchd_internalServer.h"
</span><span class="cx"> #include "launchd_internal.h"
</span><span class="cx"> #include "notifyServer.h"
</span><ins>+#include "mach_excServer.h"
</ins><span class="cx">
</span><span class="cx"> /* We shouldn't be including these */
</span><span class="cx"> #include "launch.h"
</span><span class="lines">@@ -86,6 +87,7 @@
</span><span class="cx"> static void *kqueue_demand_loop(void *arg);
</span><span class="cx"> static void log_kevent_struct(int level, struct kevent *kev, int indx);
</span><span class="cx">
</span><ins>+static boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply);
</ins><span class="cx"> static void record_caller_creds(mach_msg_header_t *mh);
</span><span class="cx"> static void launchd_runtime2(mach_msg_size_t msg_size, mig_reply_error_t *bufRequest, mig_reply_error_t *bufReply);
</span><span class="cx"> static mach_msg_size_t max_msg_size;
</span><span class="lines">@@ -115,6 +117,12 @@
</span><span class="cx"> };
</span><span class="cx"> static sigset_t sigign_set;
</span><span class="cx">
</span><ins>+mach_port_t
+runtime_get_kernel_port(void)
+{
+        return launchd_internal_port;
+}
+
</ins><span class="cx"> void
</span><span class="cx"> launchd_runtime_init(void)
</span><span class="cx"> {
</span><span class="lines">@@ -846,9 +854,11 @@
</span><span class="cx"> {
</span><span class="cx">         if (launchd_internal_server_routine(Request)) {
</span><span class="cx">                 return launchd_internal_server(Request, Reply);
</span><ins>+        } else if (notify_server_routine(Request)) {
+                return notify_server(Request, Reply);
+        } else {
+                return mach_exc_server(Request, Reply);
</ins><span class="cx">         }
</span><del>-
-        return notify_server(Request, Reply);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> kern_return_t
</span><span class="lines">@@ -1450,3 +1460,49 @@
</span><span class="cx"> {
</span><span class="cx">         runtime_busy_cnt--;
</span><span class="cx"> }
</span><ins>+
+kern_return_t
+catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task,
+                exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt)
+{
+        runtime_syslog(LOG_NOTICE, "%s(): thread: 0x%x task: 0x%x type: 0x%x code: %p codeCnt: 0x%x",
+                        __func__, thread, task, exception, code, codeCnt);
+
+        launchd_assumes(launchd_mport_deallocate(thread) == KERN_SUCCESS);
+        launchd_assumes(launchd_mport_deallocate(task) == KERN_SUCCESS);
+
+        return 0;
+}
+
+kern_return_t
+catch_mach_exception_raise_state(mach_port_t exception_port,
+                exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt,
+                int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt,
+                thread_state_t new_state, mach_msg_type_number_t *new_stateCnt)
+{
+        runtime_syslog(LOG_NOTICE, "%s(): type: 0x%x code: %p codeCnt: 0x%x flavor: %p old_state: %p old_stateCnt: 0x%x new_state: %p new_stateCnt: %p",
+                        __func__, exception, code, codeCnt, flavor, old_state, old_stateCnt, new_state, new_stateCnt);
+
+        memcpy(new_state, old_state, old_stateCnt * sizeof(old_state[0]));
+        *new_stateCnt = old_stateCnt;
+
+        return 0;
+}
+
+kern_return_t
+catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task,
+                exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt,
+                int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt,
+                thread_state_t new_state, mach_msg_type_number_t *new_stateCnt)
+{
+        runtime_syslog(LOG_NOTICE, "%s(): thread: 0x%x task: 0x%x type: 0x%x code: %p codeCnt: 0x%x flavor: %p old_state: %p old_stateCnt: 0x%x new_state: %p new_stateCnt: %p",
+                        __func__, thread, task, exception, code, codeCnt, flavor, old_state, old_stateCnt, new_state, new_stateCnt);
+
+        memcpy(new_state, old_state, old_stateCnt * sizeof(old_state[0]));
+        *new_stateCnt = old_stateCnt;
+
+        launchd_assumes(launchd_mport_deallocate(thread) == KERN_SUCCESS);
+        launchd_assumes(launchd_mport_deallocate(task) == KERN_SUCCESS);
+
+        return 0;
+}
</ins></span></pre></div>
<a id="branchesSULeopardlaunchdsrclaunchd_runtimeh"></a>
<div class="modfile"><h4>Modified: branches/SULeopard/launchd/src/launchd_runtime.h (23458 => 23459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/SULeopard/launchd/src/launchd_runtime.h        2007-12-07 21:06:19 UTC (rev 23458)
+++ branches/SULeopard/launchd/src/launchd_runtime.h        2007-12-07 21:15:23 UTC (rev 23459)
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx"> typedef boolean_t (*mig_callback)(mach_msg_header_t *, mach_msg_header_t *);
</span><span class="cx"> typedef void (*timeout_callback)(void);
</span><span class="cx">
</span><del>-boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply);
</del><ins>+mach_port_t runtime_get_kernel_port(void);
</ins><span class="cx">
</span><span class="cx"> void runtime_add_ref(void);
</span><span class="cx"> void runtime_del_ref(void);
</span></span></pre></div>
<a id="branchesSULeopardlaunchdsrcliblaunch_privateh"></a>
<div class="modfile"><h4>Modified: branches/SULeopard/launchd/src/liblaunch_private.h (23458 => 23459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/SULeopard/launchd/src/liblaunch_private.h        2007-12-07 21:06:19 UTC (rev 23458)
+++ branches/SULeopard/launchd/src/liblaunch_private.h        2007-12-07 21:15:23 UTC (rev 23459)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> #define LAUNCH_JOBKEY_PERJOBMACHSERVICES        "PerJobMachServices"
</span><span class="cx"> #define LAUNCH_JOBKEY_SERVICEIPC                "ServiceIPC"
</span><span class="cx"> #define LAUNCH_JOBKEY_BINARYORDERPREFERENCE        "BinaryOrderPreference"
</span><ins>+#define LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER        "MachExceptionHandler"
</ins><span class="cx">
</span><span class="cx"> #define LAUNCH_JOBKEY_MACH_KUNCSERVER        "kUNCServer"
</span><span class="cx"> #define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER        "ExceptionServer"
</span></span></pre>
</div>
</div>
</body>
</html>