Projects
Browse Source     Search     Timeline     Wiki

Changeset 23602

Show
Ignore:
Timestamp:
04/21/08 14:41:09 (8 months ago)
Author:
zarzycki@…
Message:

<rdar://problem/5836108> Need launchd 'trykill' SPI

Location:
trunk/launchd/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/launchd_core_logic.c

    r23601 r23602  
    702702        } 
    703703 
     704        if (j->kill_via_shmem && (tmp = launch_data_new_bool(true))) { 
     705                uint32_t tmp_cnt = -1; 
     706 
     707                launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_ENABLETRANSACTIONS); 
     708 
     709                if (j->shmem) { 
     710                        tmp_cnt = j->shmem->vp_shmem_transaction_cnt; 
     711                } 
     712 
     713                if (j->sent_kill_via_shmem) { 
     714                        tmp_cnt++; 
     715                } 
     716 
     717                if ((tmp = launch_data_new_integer(tmp_cnt))) { 
     718                        launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_TRANSACTIONCOUNT); 
     719                } 
     720        } 
     721 
    704722        if (j->session_create && (tmp = launch_data_new_bool(true))) { 
    705723                launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_SESSIONCREATE); 
     
    57095727                        return 0; 
    57105728                } 
     5729        } else if (sig == VPROC_MAGIC_TRYKILL_SIGNAL) { 
     5730                if (!j->kill_via_shmem) { 
     5731                        return BOOTSTRAP_NOT_PRIVILEGED; 
     5732                } 
     5733 
     5734                if (!j->shmem) { 
     5735                        j->sent_kill_via_shmem = true; 
     5736                        job_assumes(j, runtime_kill(otherj->p, SIGKILL) != -1); 
     5737                        return 0; 
     5738                } 
     5739 
     5740                if (__sync_bool_compare_and_swap(&j->shmem->vp_shmem_transaction_cnt, 0, -1)) { 
     5741                        j->shmem->vp_shmem_flags |= VPROC_SHMEM_EXITING; 
     5742                        j->sent_kill_via_shmem = true; 
     5743                        job_assumes(j, runtime_kill(otherj->p, SIGKILL) != -1); 
     5744                        return 0; 
     5745                } 
     5746 
     5747                return BOOTSTRAP_NOT_PRIVILEGED; 
    57115748        } else if (otherj->p) { 
    57125749                job_assumes(j, runtime_kill(otherj->p, sig) != -1); 
  • trunk/launchd/src/liblaunch_private.h

    r23503 r23602  
    4747#define LAUNCH_KEY_BATCHQUERY           "BatchQuery" 
    4848 
     49#define LAUNCH_JOBKEY_TRANSACTIONCOUNT  "TransactionCount" 
    4950#define LAUNCH_JOBKEY_QUARANTINEDATA    "QuarantineData" 
    5051#define LAUNCH_JOBKEY_SANDBOXPROFILE    "SandboxProfile" 
  • trunk/launchd/src/libvproc.c

    r23580 r23602  
    133133_vproc_transaction_try_exit(int status) 
    134134{ 
    135         typeof(vproc_shmem->vp_shmem_transaction_cnt) newval; 
    136  
    137135        if (unlikely(vproc_shmem == NULL)) { 
    138136                return; 
    139137        } 
    140138 
    141         vproc_shmem->vp_shmem_flags |= VPROC_SHMEM_EXITING; 
    142  
    143         newval = __sync_sub_and_fetch(&vproc_shmem->vp_shmem_transaction_cnt, 1); 
    144  
    145         if (newval < 0) { 
     139        if (__sync_bool_compare_and_swap(&vproc_shmem->vp_shmem_transaction_cnt, 0, -1)) { 
     140                vproc_shmem->vp_shmem_flags |= VPROC_SHMEM_EXITING; 
    146141                _exit(status); 
    147142        } 
  • trunk/launchd/src/libvproc_private.h

    r23590 r23602  
    3232#pragma GCC visibility push(default) 
    3333 
    34 /* DO NOT use this. This is a hack for launchctl */ 
    35 #define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C 
     34/* DO NOT use this. This is a hack for 'launchctl' */ 
     35#define VPROC_MAGIC_UNLOAD_SIGNAL       0x4141504C 
     36/* DO NOT use this. This is a hack for 'loginwindow' */ 
     37#define VPROC_MAGIC_TRYKILL_SIGNAL      0x6161706C 
    3638 
    3739typedef enum {