]> git.saurik.com Git - apple/launchd.git/blame - launchd/src/launchd.h
launchd-152.tar.gz
[apple/launchd.git] / launchd / src / launchd.h
CommitLineData
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
44struct kevent;
45struct conncb;
fc89531e 46
e91b9f68
A
47typedef void (*kq_callback)(void *, struct kevent *);
48
49extern kq_callback kqsimple_zombie_reaper;
e91b9f68 50extern sigset_t blocked_signals;
ed34e3c3
A
51extern bool shutdown_in_progress;
52extern bool network_up;
53extern int batch_disabler_count;
54extern mach_port_t launchd_internal_port;
55extern mach_port_t ipc_port_set;
e91b9f68 56
ed34e3c3 57bool init_check_pid(pid_t);
e91b9f68
A
58
59int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata);
ed34e3c3
A
60void batch_job_enable(bool e, struct conncb *c);
61
62launch_data_t launchd_setstdio(int d, launch_data_t o);
63void launchd_SessionCreate(void);
64void launchd_shutdown(void);
65void launchd_single_user(void);
66pid_t launchd_fork(void);
67boolean_t launchd_mach_ipc_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply);
e91b9f68 68
ed34e3c3
A
69kern_return_t launchd_set_bport(mach_port_t name);
70kern_return_t launchd_get_bport(mach_port_t *name);
71kern_return_t launchd_mport_notify_req(mach_port_t name, mach_msg_id_t which);
72kern_return_t launchd_mport_notify_cancel(mach_port_t name, mach_msg_id_t which);
73kern_return_t launchd_mport_request_callback(mach_port_t name, void *obj, bool readmsg);
74kern_return_t launchd_mport_create_recv(mach_port_t *name);
75kern_return_t launchd_mport_deallocate(mach_port_t name);
76kern_return_t launchd_mport_make_send(mach_port_t name);
77kern_return_t launchd_mport_close_recv(mach_port_t name);
78
79void init_boot(bool sflag);
e91b9f68 80void init_pre_kevent(void);
e91b9f68
A
81
82void update_ttys(void);
83void catatonia(void);
ed34e3c3
A
84
85void mach_start_shutdown(void);
86void mach_init_init(mach_port_t, mach_port_t, name_array_t, mach_port_array_t, mach_msg_type_number_t);
87void mach_init_reap(void);
88
89int _fd(int fd);
90
91void _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test);
92
93bool progeny_check(pid_t p);
e91b9f68
A
94
95#endif