* @APPLE_APACHE_LICENSE_HEADER_END@
*/
-#define LAUNCHD_MIN_JOB_RUN_TIME 10
-#define LAUNCHD_REWARD_JOB_RUN_TIME 60
-#define LAUNCHD_FAILED_EXITS_THRESHOLD 10
+#include "launchd_runtime.h"
+#include "bootstrap.h"
+#include "launch.h"
-#include "bootstrap_public.h"
+typedef struct job_s *job_t;
+typedef struct jobmgr_s *jobmgr_t;
-struct jobcb;
-struct machservice;
+extern jobmgr_t root_jobmgr;
+extern mach_port_t inherited_bootstrap_port;
+extern mach_port_t g_audit_session_port;
+extern au_asid_t g_audit_session;
+extern bool g_flat_mach_namespace;
+extern bool g_embedded_privileged_action;
+void jobmgr_init(bool);
+jobmgr_t jobmgr_shutdown(jobmgr_t jm);
+void jobmgr_dispatch_all_semaphores(jobmgr_t jm);
+void jobmgr_dispatch_all_interested(jobmgr_t jm, job_t j);
+jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port);
-struct machservice *machservice_new(struct jobcb *j, const char *name, mach_port_t *serviceport);
-void machservice_delete(struct machservice *);
-void machservice_watch(struct machservice *);
-mach_port_t machservice_port(struct machservice *);
-struct jobcb *machservice_job(struct machservice *);
-bool machservice_hidden(struct machservice *);
-bool machservice_active(struct machservice *);
-const char *machservice_name(struct machservice *);
-bootstrap_status_t machservice_status(struct machservice *);
-
-
-struct jobcb *job_find(struct jobcb *j, const char *label);
-struct jobcb *job_find_by_pid(struct jobcb *j, pid_t p);
-struct jobcb *job_find_by_port(mach_port_t mp);
-struct jobcb *job_import(launch_data_t pload);
-launch_data_t job_import_bulk(launch_data_t pload);
-struct jobcb *job_new(struct jobcb *p, const char *label, const char *prog, const char *const *argv, const char *stdinpath, mach_port_t);
-struct jobcb *job_new_spawn(const char *label, const char *path, const char *workingdir, const char *const *argv, const char *const *env, mode_t *u_mask, bool w4d, bool fppc);
-struct jobcb *job_new_via_mach_init(struct jobcb *jbs, const char *cmd, uid_t uid, bool ond);
-struct jobcb *job_new_bootstrap(struct jobcb *p, mach_port_t requestorport, mach_port_t checkin_port);
-launch_data_t job_export(struct jobcb *j);
launch_data_t job_export_all(void);
-void job_dispatch(struct jobcb *j);
-void job_dispatch_all_other_semaphores(struct jobcb *j, struct jobcb *nj);
-void job_start(struct jobcb *j);
-void job_stop(struct jobcb *j);
-bool job_active(struct jobcb *j);
-void job_checkin(struct jobcb *j);
-const char *job_prog(struct jobcb *j);
-void job_remove(struct jobcb *j);
-void job_remove_all_inactive(struct jobcb *j);
-bool job_ack_port_destruction(struct jobcb *j, mach_port_t p);
-void job_ack_no_senders(struct jobcb *j);
-pid_t job_get_pid(struct jobcb *j);
-mach_port_t job_get_bsport(struct jobcb *j);
-mach_port_t job_get_reqport(struct jobcb *j);
-struct jobcb *job_get_bs(struct jobcb *j);
-void job_delete_anything_with_port(struct jobcb *jbs, mach_port_t port);
-struct jobcb *job_parent(struct jobcb *j);
-void job_uncork_fork(struct jobcb *j);
-struct machservice *job_lookup_service(struct jobcb *jbs, const char *name, bool check_parent);
-void job_foreach_service(struct jobcb *jbs, void (*bs_iter)(struct machservice *, void *), void *context, bool include_subjobs);
-void job_log(struct jobcb *j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
-void job_log_error(struct jobcb *j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
-kern_return_t job_handle_mpm_wait(struct jobcb *j, mach_port_t srp, int *waitstatus);
-extern size_t total_children;
-
-extern struct jobcb *root_job;
+job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */
+job_t job_find(jobmgr_t jm, const char *label);
+job_t job_find_by_service_port(mach_port_t p);
+bool job_ack_port_destruction(mach_port_t p);
+bool job_is_anonymous(job_t j);
+launch_data_t job_export(job_t j);
+void job_stop(job_t j);
+void job_checkin(job_t j);
+void job_remove(job_t j);
+bool job_is_god(job_t j);
+job_t job_import(launch_data_t pload);
+launch_data_t job_import_bulk(launch_data_t pload);
+job_t job_mig_intran(mach_port_t mp);
+void job_mig_destructor(job_t j);
+void job_ack_no_senders(job_t j);
+void job_log(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
+void job_set_pid_crashed(pid_t p);
-extern struct jobcb *gc_this_job;
+int launchd_set_jetsam_priorities(launch_data_t priorities);
#endif