]> git.saurik.com Git - apple/launchd.git/blame_incremental - liblaunch/vproc_priv.h
launchd-842.92.1.tar.gz
[apple/launchd.git] / liblaunch / vproc_priv.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2006-2012 Apple 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 __VPROC_PRIVATE_H__
22#define __VPROC_PRIVATE_H__
23
24#include <Availability.h>
25#include <sys/types.h>
26#include <sys/cdefs.h>
27#include <sys/syslog.h>
28#include <sys/time.h>
29#include <stdbool.h>
30#include <launch.h>
31#include <vproc.h>
32#include <uuid/uuid.h>
33#include <servers/bootstrap.h>
34#include <dispatch/dispatch.h>
35
36#ifndef VPROC_HAS_TRANSACTIONS
37#define VPROC_HAS_TRANSACTIONS 1
38#endif
39
40__BEGIN_DECLS
41
42#define VPROCMGR_SESSION_LOGINWINDOW "LoginWindow"
43#define VPROCMGR_SESSION_BACKGROUND "Background"
44#define VPROCMGR_SESSION_AQUA "Aqua"
45#define VPROCMGR_SESSION_STANDARDIO "StandardIO"
46#define VPROCMGR_SESSION_SYSTEM "System"
47
48#define XPC_DOMAIN_TYPE_SYSTEM "XPCSystem"
49#define XPC_DOMAIN_TYPE_PERUSER "XPCPerUser"
50#define XPC_DOMAIN_TYPE_PERSESSION "XPCPerSession"
51#define XPC_DOMAIN_TYPE_PERAPPLICATION "XPCPerApplication"
52
53#pragma GCC visibility push(default)
54
55/* DO NOT use this. This is a hack for 'launchctl' */
56#define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C
57
58typedef void (*_vproc_transaction_callout)(void *);
59
60typedef enum {
61 VPROC_GSK_ZERO,
62 VPROC_GSK_LAST_EXIT_STATUS,
63 VPROC_GSK_GLOBAL_ON_DEMAND,
64 VPROC_GSK_MGR_UID,
65 VPROC_GSK_MGR_PID,
66 VPROC_GSK_IS_MANAGED,
67 VPROC_GSK_MGR_NAME,
68 VPROC_GSK_BASIC_KEEPALIVE,
69 VPROC_GSK_START_INTERVAL,
70 VPROC_GSK_IDLE_TIMEOUT,
71 VPROC_GSK_EXIT_TIMEOUT,
72 VPROC_GSK_ENVIRONMENT,
73 VPROC_GSK_ALLJOBS,
74 VPROC_GSK_GLOBAL_LOG_MASK,
75 VPROC_GSK_GLOBAL_UMASK,
76 VPROC_GSK_ABANDON_PROCESS_GROUP,
77 VPROC_GSK_TRANSACTIONS_ENABLED,
78 VPROC_GSK_WEIRD_BOOTSTRAP,
79 VPROC_GSK_WAITFORDEBUGGER,
80 VPROC_GSK_SECURITYSESSION,
81 VPROC_GSK_SHUTDOWN_DEBUGGING,
82 VPROC_GSK_VERBOSE_BOOT,
83 VPROC_GSK_PERUSER_SUSPEND,
84 VPROC_GSK_PERUSER_RESUME,
85 VPROC_GSK_JOB_OVERRIDES_DB,
86 VPROC_GSK_JOB_CACHE_DB,
87 VPROC_GSK_EMBEDDEDROOTEQUIVALENT,
88} vproc_gsk_t;
89
90typedef unsigned int vproc_flags_t;
91/* For _vproc_kickstart_by_label() -- instructs launchd to kickstart the job to stall before exec(2). */
92#define VPROCFLAG_STALL_JOB_EXEC 1 << 1
93
94__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0)
95vproc_t
96vprocmgr_lookup_vproc(const char *label);
97
98__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0)
99vproc_t
100vproc_retain(vproc_t vp);
101
102__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0)
103void
104vproc_release(vproc_t vp);
105
106__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0)
107vproc_err_t
108vproc_swap_integer(vproc_t vp, vproc_gsk_t key,
109 int64_t *inval, int64_t *outval);
110
111__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0)
112vproc_err_t
113vproc_swap_complex(vproc_t vp, vproc_gsk_t key,
114 launch_data_t inval, launch_data_t *outval);
115
116__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_4_0)
117vproc_err_t
118vproc_swap_string(vproc_t vp, vproc_gsk_t key,
119 const char *instr, char **outstr);
120
121__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA)
122vproc_err_t
123_vproc_get_last_exit_status(int *wstatus);
124
125__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0)
126vproc_err_t
127_vproc_set_global_on_demand(bool val);
128
129__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0)
130vproc_err_t
131_vproc_send_signal_by_label(const char *label, int sig);
132
133__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0)
134vproc_err_t
135_vproc_kickstart_by_label(const char *label, pid_t *out_pid,
136 mach_port_t *out_port_name, mach_port_t *out_obsrvr_port,
137 vproc_flags_t flags);
138
139/* _vprocmgr_log_drain() is specific to syslogd. It is not for general use. */
140typedef void (*_vprocmgr_log_drain_callback_t)(struct timeval *when, pid_t
141 from_pid, pid_t about_pid, uid_t sender_uid, gid_t sender_gid, int priority,
142 const char *from_name, const char *about_name, const char *session_name,
143 const char *msg);
144
145vproc_err_t
146_vprocmgr_log_drain(vproc_t vp, pthread_mutex_t *optional_mutex_around_callback,
147 _vprocmgr_log_drain_callback_t func);
148
149__attribute__((format(printf, 2, 3)))
150void
151_vproc_log(int pri, const char *msg, ...);
152
153__attribute__((format(printf, 2, 3)))
154void
155_vproc_log_error(int pri, const char *msg, ...);
156
157__attribute__((format(printf, 3, 0)))
158void
159_vproc_logv(int pri, int err, const char *msg, va_list ap);
160
161/* One day, we'll be able to get rid of this... */
162vproc_err_t
163_vprocmgr_move_subset_to_user(uid_t target_user, const char *session_type,
164 uint64_t flags);
165
166vproc_err_t
167_vprocmgr_switch_to_session(const char *target_session, vproc_flags_t flags);
168
169vproc_err_t
170_vprocmgr_detach_from_console(vproc_flags_t flags);
171
172__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
173void
174_vproc_standby_begin(void);
175
176__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
177void
178_vproc_standby_end(void);
179
180__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
181size_t
182_vproc_standby_count(void);
183
184__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
185size_t
186_vproc_standby_timeout(void);
187
188__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
189kern_return_t
190_vproc_transaction_count_for_pid(pid_t p, int32_t *count, bool *condemned);
191
192__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
193bool
194_vproc_pid_is_managed(pid_t p);
195
196__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
197void
198_vproc_transaction_try_exit(int status);
199
200__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0)
201void
202_vproc_transaction_begin(void);
203
204__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0)
205void
206_vproc_transaction_end(void);
207
208__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
209size_t
210_vproc_transaction_count(void);
211
212void
213_vproc_transaction_set_clean_callback(dispatch_queue_t targetq, void *ctx,
214 dispatch_function_t func);
215
216void
217_vproc_transactions_enable(void);
218
219#pragma GCC visibility pop
220
221__END_DECLS
222
223#endif /* __VPROC_PRIVATE_H__ */