1 /* 2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_APACHE_LICENSE_HEADER_START@ 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 * @APPLE_APACHE_LICENSE_HEADER_END@ 19 */ 20 21 #ifndef __LAUNCHD_CORE_LOGIC__ 22 #define __LAUNCHD_CORE_LOGIC__ 23 24 #include "runtime.h" 25 #include "bootstrap.h" 26 #include "launch.h" 27 #include <xpc/xpc.h> 28 29 #ifndef JOB_T_DEFINED 30 #define JOB_T_DEFINED 31 typedef struct job_s *job_t; 32 #endif 33 typedef struct jobmgr_s *jobmgr_t; 34 35 extern jobmgr_t root_jobmgr; 36 extern mach_port_t launchd_audit_port; 37 extern au_asid_t launchd_audit_session; 38 extern bool launchd_flat_mach_namespace; 39 extern bool launchd_embedded_handofgod; 40 41 void jobmgr_init(bool); 42 mach_port_t jobmgr_port(jobmgr_t); 43 jobmgr_t jobmgr_shutdown(jobmgr_t jm); 44 void jobmgr_dispatch_all_semaphores(jobmgr_t jm); 45 void jobmgr_dispatch_all_interested(jobmgr_t jm, job_t j); 46 jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port); 47 void jobmgr_reap_pid(jobmgr_t jm, pid_t pid); 48 49 launch_data_t job_export_all(void); 50 51 job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */ 52 job_t job_find(jobmgr_t jm, const char *label); 53 job_t job_find_by_service_port(mach_port_t p); 54 bool job_ack_port_destruction(mach_port_t p); 55 bool job_is_anonymous(job_t j); 56 launch_data_t job_export(job_t j); 57 void job_stop(job_t j); 58 void job_checkin(job_t j); 59 void job_remove(job_t j); 60 bool job_is_god(job_t j); 61 job_t job_import(launch_data_t pload); 62 launch_data_t job_import_bulk(launch_data_t pload); 63 job_t job_mig_intran(mach_port_t mp); 64 void job_mig_destructor(job_t j); 65 void job_ack_no_senders(job_t j); 66 void job_log(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); 67 void job_set_pid_crashed(pid_t p); 68 69 bool xpc_event_demux(mach_port_t p, xpc_object_t request, xpc_object_t *reply); 70 bool xpc_process_demux(mach_port_t p, xpc_object_t request, xpc_object_t *reply); 71 72 #endif /* __LAUNCHD_CORE_LOGIC__ */ 73