Modified: trunk/launchd/src/launchd_core_logic.c (23601 => 23602)
--- trunk/launchd/src/launchd_core_logic.c 2008-04-21 20:33:29 UTC (rev 23601)
+++ trunk/launchd/src/launchd_core_logic.c 2008-04-21 21:41:09 UTC (rev 23602)
@@ -701,6 +701,24 @@
launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_PROGRAMARGUMENTS);
}
+ if (j->kill_via_shmem && (tmp = launch_data_new_bool(true))) {
+ uint32_t tmp_cnt = -1;
+
+ launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_ENABLETRANSACTIONS);
+
+ if (j->shmem) {
+ tmp_cnt = j->shmem->vp_shmem_transaction_cnt;
+ }
+
+ if (j->sent_kill_via_shmem) {
+ tmp_cnt++;
+ }
+
+ if ((tmp = launch_data_new_integer(tmp_cnt))) {
+ launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_TRANSACTIONCOUNT);
+ }
+ }
+
if (j->session_create && (tmp = launch_data_new_bool(true))) {
launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_SESSIONCREATE);
}
@@ -5708,6 +5726,25 @@
} else {
return 0;
}
+ } else if (sig == VPROC_MAGIC_TRYKILL_SIGNAL) {
+ if (!j->kill_via_shmem) {
+ return BOOTSTRAP_NOT_PRIVILEGED;
+ }
+
+ if (!j->shmem) {
+ j->sent_kill_via_shmem = true;
+ job_assumes(j, runtime_kill(otherj->p, SIGKILL) != -1);
+ return 0;
+ }
+
+ if (__sync_bool_compare_and_swap(&j->shmem->vp_shmem_transaction_cnt, 0, -1)) {
+ j->shmem->vp_shmem_flags |= VPROC_SHMEM_EXITING;
+ j->sent_kill_via_shmem = true;
+ job_assumes(j, runtime_kill(otherj->p, SIGKILL) != -1);
+ return 0;
+ }
+
+ return BOOTSTRAP_NOT_PRIVILEGED;
} else if (otherj->p) {
job_assumes(j, runtime_kill(otherj->p, sig) != -1);
}
Modified: trunk/launchd/src/liblaunch_private.h (23601 => 23602)
--- trunk/launchd/src/liblaunch_private.h 2008-04-21 20:33:29 UTC (rev 23601)
+++ trunk/launchd/src/liblaunch_private.h 2008-04-21 21:41:09 UTC (rev 23602)
@@ -46,6 +46,7 @@
#define LAUNCH_KEY_BATCHCONTROL "BatchControl"
#define LAUNCH_KEY_BATCHQUERY "BatchQuery"
+#define LAUNCH_JOBKEY_TRANSACTIONCOUNT "TransactionCount"
#define LAUNCH_JOBKEY_QUARANTINEDATA "QuarantineData"
#define LAUNCH_JOBKEY_SANDBOXPROFILE "SandboxProfile"
#define LAUNCH_JOBKEY_SANDBOXFLAGS "SandboxFlags"
Modified: trunk/launchd/src/libvproc.c (23601 => 23602)
--- trunk/launchd/src/libvproc.c 2008-04-21 20:33:29 UTC (rev 23601)
+++ trunk/launchd/src/libvproc.c 2008-04-21 21:41:09 UTC (rev 23602)
@@ -132,17 +132,12 @@
void
_vproc_transaction_try_exit(int status)
{
- typeof(vproc_shmem->vp_shmem_transaction_cnt) newval;
-
if (unlikely(vproc_shmem == NULL)) {
return;
}
- vproc_shmem->vp_shmem_flags |= VPROC_SHMEM_EXITING;
-
- newval = __sync_sub_and_fetch(&vproc_shmem->vp_shmem_transaction_cnt, 1);
-
- if (newval < 0) {
+ if (__sync_bool_compare_and_swap(&vproc_shmem->vp_shmem_transaction_cnt, 0, -1)) {
+ vproc_shmem->vp_shmem_flags |= VPROC_SHMEM_EXITING;
_exit(status);
}
}
Modified: trunk/launchd/src/libvproc_private.h (23601 => 23602)
--- trunk/launchd/src/libvproc_private.h 2008-04-21 20:33:29 UTC (rev 23601)
+++ trunk/launchd/src/libvproc_private.h 2008-04-21 21:41:09 UTC (rev 23602)
@@ -31,8 +31,10 @@
#pragma GCC visibility push(default)
-/* DO NOT use this. This is a hack for launchctl */
-#define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C
+/* DO NOT use this. This is a hack for 'launchctl' */
+#define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C
+/* DO NOT use this. This is a hack for 'loginwindow' */
+#define VPROC_MAGIC_TRYKILL_SIGNAL 0x6161706C
typedef enum {
VPROC_GSK_LAST_EXIT_STATUS = 1,