2 * Copyright (c) 2006-2012 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
21 #ifndef __VPROC_PRIVATE_H__
22 #define __VPROC_PRIVATE_H__
24 #include <Availability.h>
25 #include <sys/types.h>
26 #include <sys/cdefs.h>
27 #include <sys/syslog.h>
32 #include <uuid/uuid.h>
33 #include <servers/bootstrap.h>
34 #include <dispatch/dispatch.h>
36 #ifndef VPROC_HAS_TRANSACTIONS
37 #define VPROC_HAS_TRANSACTIONS 1
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"
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"
53 #pragma GCC visibility push(default)
55 /* DO NOT use this. This is a hack for 'launchctl' */
56 #define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C
58 typedef void (*_vproc_transaction_callout
)(void *);
62 VPROC_GSK_LAST_EXIT_STATUS
,
63 VPROC_GSK_GLOBAL_ON_DEMAND
,
68 VPROC_GSK_BASIC_KEEPALIVE
,
69 VPROC_GSK_START_INTERVAL
,
70 VPROC_GSK_IDLE_TIMEOUT
,
71 VPROC_GSK_EXIT_TIMEOUT
,
72 VPROC_GSK_ENVIRONMENT
,
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
,
90 typedef 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
94 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_3_0
)
96 vprocmgr_lookup_vproc(const char *label
);
98 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_3_0
)
100 vproc_retain(vproc_t vp
);
102 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_3_0
)
104 vproc_release(vproc_t vp
);
106 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_3_0
)
108 vproc_swap_integer(vproc_t vp
, vproc_gsk_t key
,
109 int64_t *inval
, int64_t *outval
);
111 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_3_0
)
113 vproc_swap_complex(vproc_t vp
, vproc_gsk_t key
,
114 launch_data_t inval
, launch_data_t
*outval
);
116 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_4_0
)
118 vproc_swap_string(vproc_t vp
, vproc_gsk_t key
,
119 const char *instr
, char **outstr
);
121 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_NA
)
123 _vproc_get_last_exit_status(int *wstatus
);
125 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_3_0
)
127 _vproc_set_global_on_demand(bool val
);
129 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_3_0
)
131 _vproc_send_signal_by_label(const char *label
, int sig
);
133 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_3_0
)
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
);
139 /* _vprocmgr_log_drain() is specific to syslogd. It is not for general use. */
140 typedef 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
,
146 _vprocmgr_log_drain(vproc_t vp
, pthread_mutex_t
*optional_mutex_around_callback
,
147 _vprocmgr_log_drain_callback_t func
);
149 __attribute__((format(printf
, 2, 3)))
151 _vproc_log(int pri
, const char *msg
, ...);
153 __attribute__((format(printf
, 2, 3)))
155 _vproc_log_error(int pri
, const char *msg
, ...);
157 __attribute__((format(printf
, 3, 0)))
159 _vproc_logv(int pri
, int err
, const char *msg
, va_list ap
);
161 /* One day, we'll be able to get rid of this... */
163 _vprocmgr_move_subset_to_user(uid_t target_user
, const char *session_type
,
167 _vprocmgr_switch_to_session(const char *target_session
, vproc_flags_t flags
);
170 _vprocmgr_detach_from_console(vproc_flags_t flags
);
172 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_NA
)
174 _vproc_standby_begin(void);
176 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_NA
)
178 _vproc_standby_end(void);
180 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_NA
)
182 _vproc_standby_count(void);
184 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_NA
)
186 _vproc_standby_timeout(void);
188 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_NA
)
190 _vproc_transaction_count_for_pid(pid_t p
, int32_t *count
, bool *condemned
);
192 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_NA
)
194 _vproc_pid_is_managed(pid_t p
);
196 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_NA
)
198 _vproc_transaction_try_exit(int status
);
200 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_5_0
)
202 _vproc_transaction_begin(void);
204 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_5_0
)
206 _vproc_transaction_end(void);
208 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_NA
)
210 _vproc_transaction_count(void);
213 _vproc_transaction_set_clean_callback(dispatch_queue_t targetq
, void *ctx
,
214 dispatch_function_t func
);
217 _vproc_transactions_enable(void);
219 #pragma GCC visibility pop
223 #endif /* __VPROC_PRIVATE_H__ */