[launchd-changes] [23602] trunk/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 21 14:41:10 PDT 2008
Revision: 23602
http://trac.macosforge.org/projects/launchd/changeset/23602
Author: zarzycki at apple.com
Date: 2008-04-21 14:41:09 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
<rdar://problem/5836108> Need launchd 'trykill' SPI
Modified Paths:
--------------
trunk/launchd/src/launchd_core_logic.c
trunk/launchd/src/liblaunch_private.h
trunk/launchd/src/libvproc.c
trunk/launchd/src/libvproc_private.h
Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- 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
===================================================================
--- 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
===================================================================
--- 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
===================================================================
--- 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,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080421/05a5a6f0/attachment-0001.html
More information about the launchd-changes
mailing list