]>
Commit | Line | Data |
---|---|---|
e91b9f68 A |
1 | /* |
2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. | |
3 | * | |
ed34e3c3 | 4 | * @APPLE_APACHE_LICENSE_HEADER_START@ |
e91b9f68 | 5 | * |
ed34e3c3 A |
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 | |
e91b9f68 | 9 | * |
ed34e3c3 A |
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 | |
e91b9f68 A |
16 | * limitations under the License. |
17 | * | |
ed34e3c3 | 18 | * @APPLE_APACHE_LICENSE_HEADER_END@ |
e91b9f68 A |
19 | */ |
20 | #ifndef __LAUNCHD_H__ | |
21 | #define __LAUNCHD_H__ | |
22 | ||
ed34e3c3 A |
23 | #include <mach/mach.h> |
24 | #include <mach/port.h> | |
25 | #include "launch.h" | |
26 | #include "bootstrap_public.h" | |
27 | ||
28 | /* | |
29 | * Use launchd_assumes() when we can recover, even if it means we leak or limp along. | |
30 | * | |
31 | * Use launchd_assert() for core initialization routines. | |
32 | */ | |
33 | #define launchd_assumes(e) \ | |
34 | (__builtin_expect(!(e), 0) ? _log_launchd_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true) | |
35 | ||
36 | #define launchd_blame(e, b) \ | |
37 | (__builtin_expect(!(e), 0) ? syslog(LOG_DEBUG, "Encountered bug: %d", b), false : true) | |
e91b9f68 | 38 | |
ed34e3c3 | 39 | #define launchd_assert(e) launchd_assumes(e) ? true : abort(); |
fc89531e | 40 | |
ed34e3c3 A |
41 | #define FIRSTBORN_LABEL "com.apple.launchd.firstborn" |
42 | #define READCONF_LABEL "com.apple.launchd.readconfig" | |
43 | ||
44 | struct kevent; | |
45 | struct conncb; | |
fc89531e | 46 | |
e91b9f68 A |
47 | typedef void (*kq_callback)(void *, struct kevent *); |
48 | ||
49 | extern kq_callback kqsimple_zombie_reaper; | |
e91b9f68 | 50 | extern sigset_t blocked_signals; |
ed34e3c3 A |
51 | extern bool shutdown_in_progress; |
52 | extern bool network_up; | |
53 | extern int batch_disabler_count; | |
54 | extern mach_port_t launchd_internal_port; | |
55 | extern mach_port_t ipc_port_set; | |
e91b9f68 | 56 | |
ed34e3c3 | 57 | bool init_check_pid(pid_t); |
e91b9f68 A |
58 | |
59 | int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata); | |
ed34e3c3 A |
60 | void batch_job_enable(bool e, struct conncb *c); |
61 | ||
62 | launch_data_t launchd_setstdio(int d, launch_data_t o); | |
63 | void launchd_SessionCreate(void); | |
64 | void launchd_shutdown(void); | |
65 | void launchd_single_user(void); | |
66 | pid_t launchd_fork(void); | |
67 | boolean_t launchd_mach_ipc_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply); | |
e91b9f68 | 68 | |
ed34e3c3 A |
69 | kern_return_t launchd_set_bport(mach_port_t name); |
70 | kern_return_t launchd_get_bport(mach_port_t *name); | |
71 | kern_return_t launchd_mport_notify_req(mach_port_t name, mach_msg_id_t which); | |
72 | kern_return_t launchd_mport_notify_cancel(mach_port_t name, mach_msg_id_t which); | |
73 | kern_return_t launchd_mport_request_callback(mach_port_t name, void *obj, bool readmsg); | |
74 | kern_return_t launchd_mport_create_recv(mach_port_t *name); | |
75 | kern_return_t launchd_mport_deallocate(mach_port_t name); | |
76 | kern_return_t launchd_mport_make_send(mach_port_t name); | |
77 | kern_return_t launchd_mport_close_recv(mach_port_t name); | |
78 | ||
79 | void init_boot(bool sflag); | |
e91b9f68 | 80 | void init_pre_kevent(void); |
e91b9f68 A |
81 | |
82 | void update_ttys(void); | |
83 | void catatonia(void); | |
ed34e3c3 A |
84 | |
85 | void mach_start_shutdown(void); | |
86 | void mach_init_init(mach_port_t, mach_port_t, name_array_t, mach_port_array_t, mach_msg_type_number_t); | |
87 | void mach_init_reap(void); | |
88 | ||
89 | int _fd(int fd); | |
90 | ||
91 | void _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test); | |
92 | ||
93 | bool progeny_check(pid_t p); | |
e91b9f68 A |
94 | |
95 | #endif |