]> git.saurik.com Git - apple/launchd.git/blob - launchd/src/launchd_core_logic.h
launchd-152.tar.gz
[apple/launchd.git] / launchd / src / launchd_core_logic.h
1 #ifndef __LAUNCHD_CORE_LOGIC__
2 #define __LAUNCHD_CORE_LOGIC__
3 /*
4 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
5 *
6 * @APPLE_APACHE_LICENSE_HEADER_START@
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 * @APPLE_APACHE_LICENSE_HEADER_END@
21 */
22
23 #define LAUNCHD_MIN_JOB_RUN_TIME 10
24 #define LAUNCHD_REWARD_JOB_RUN_TIME 60
25 #define LAUNCHD_FAILED_EXITS_THRESHOLD 10
26
27 #include "bootstrap_public.h"
28
29 struct jobcb;
30 struct machservice;
31
32
33 struct machservice *machservice_new(struct jobcb *j, const char *name, mach_port_t *serviceport);
34 void machservice_delete(struct machservice *);
35 void machservice_watch(struct machservice *);
36 mach_port_t machservice_port(struct machservice *);
37 struct jobcb *machservice_job(struct machservice *);
38 bool machservice_hidden(struct machservice *);
39 bool machservice_active(struct machservice *);
40 const char *machservice_name(struct machservice *);
41 bootstrap_status_t machservice_status(struct machservice *);
42
43
44 struct jobcb *job_find(struct jobcb *j, const char *label);
45 struct jobcb *job_find_by_pid(struct jobcb *j, pid_t p);
46 struct jobcb *job_find_by_port(mach_port_t mp);
47 struct jobcb *job_import(launch_data_t pload);
48 launch_data_t job_import_bulk(launch_data_t pload);
49 struct jobcb *job_new(struct jobcb *p, const char *label, const char *prog, const char *const *argv, const char *stdinpath, mach_port_t);
50 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);
51 struct jobcb *job_new_via_mach_init(struct jobcb *jbs, const char *cmd, uid_t uid, bool ond);
52 struct jobcb *job_new_bootstrap(struct jobcb *p, mach_port_t requestorport, mach_port_t checkin_port);
53 launch_data_t job_export(struct jobcb *j);
54 launch_data_t job_export_all(void);
55 void job_dispatch(struct jobcb *j);
56 void job_dispatch_all_other_semaphores(struct jobcb *j, struct jobcb *nj);
57 void job_start(struct jobcb *j);
58 void job_stop(struct jobcb *j);
59 bool job_active(struct jobcb *j);
60 void job_checkin(struct jobcb *j);
61 const char *job_prog(struct jobcb *j);
62 void job_remove(struct jobcb *j);
63 void job_remove_all_inactive(struct jobcb *j);
64 bool job_ack_port_destruction(struct jobcb *j, mach_port_t p);
65 void job_ack_no_senders(struct jobcb *j);
66 pid_t job_get_pid(struct jobcb *j);
67 mach_port_t job_get_bsport(struct jobcb *j);
68 mach_port_t job_get_reqport(struct jobcb *j);
69 struct jobcb *job_get_bs(struct jobcb *j);
70 void job_delete_anything_with_port(struct jobcb *jbs, mach_port_t port);
71 struct jobcb *job_parent(struct jobcb *j);
72 void job_uncork_fork(struct jobcb *j);
73 struct machservice *job_lookup_service(struct jobcb *jbs, const char *name, bool check_parent);
74 void job_foreach_service(struct jobcb *jbs, void (*bs_iter)(struct machservice *, void *), void *context, bool include_subjobs);
75 void job_log(struct jobcb *j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
76 void job_log_error(struct jobcb *j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
77 kern_return_t job_handle_mpm_wait(struct jobcb *j, mach_port_t srp, int *waitstatus);
78
79 extern size_t total_children;
80
81 extern struct jobcb *root_job;
82
83 extern struct jobcb *gc_this_job;
84
85 #endif