]> git.saurik.com Git - apple/launchd.git/blob - launchd/src/vproc_priv.h
launchd-329.3.tar.gz
[apple/launchd.git] / launchd / src / vproc_priv.h
1 #ifndef _VPROC_PRIVATE_H_
2 #define _VPROC_PRIVATE_H_
3 /*
4 * Copyright (c) 2006 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 #include <Availability.h>
24 #include <sys/types.h>
25 #include <sys/cdefs.h>
26 #include <sys/syslog.h>
27 #include <sys/time.h>
28 #include <stdbool.h>
29 #include <launch.h>
30 #include <vproc.h>
31 #include <uuid/uuid.h>
32
33 #ifndef VPROC_HAS_TRANSACTIONS
34 #define VPROC_HAS_TRANSACTIONS
35 #endif
36
37 __BEGIN_DECLS
38
39 #pragma GCC visibility push(default)
40
41 /* DO NOT use this. This is a hack for 'launchctl' */
42 #define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C
43 /* DO NOT use this. This is a hack for 'loginwindow' */
44 #define VPROC_MAGIC_TRYKILL_SIGNAL 0x6161706C
45
46 typedef enum {
47 VPROC_GSK_LAST_EXIT_STATUS = 1,
48 VPROC_GSK_GLOBAL_ON_DEMAND,
49 VPROC_GSK_MGR_UID,
50 VPROC_GSK_MGR_PID,
51 VPROC_GSK_IS_MANAGED,
52 VPROC_GSK_MGR_NAME,
53 VPROC_GSK_BASIC_KEEPALIVE,
54 VPROC_GSK_START_INTERVAL,
55 VPROC_GSK_IDLE_TIMEOUT,
56 VPROC_GSK_EXIT_TIMEOUT,
57 VPROC_GSK_ENVIRONMENT,
58 VPROC_GSK_ALLJOBS,
59 VPROC_GSK_GLOBAL_LOG_MASK,
60 VPROC_GSK_GLOBAL_UMASK,
61 VPROC_GSK_ABANDON_PROCESS_GROUP,
62 VPROC_GSK_TRANSACTIONS_ENABLED,
63 VPROC_GSK_WEIRD_BOOTSTRAP,
64 VPROC_GSK_WAITFORDEBUGGER,
65 VPROC_GSK_SECURITYSESSION,
66 VPROC_GSK_SHUTDOWN_DEBUGGING,
67 VPROC_GSK_VERBOSE_BOOT,
68 VPROC_GSK_PERUSER_SUSPEND,
69 VPROC_GSK_PERUSER_RESUME,
70 VPROC_GSK_JOB_OVERRIDES_DB,
71 VPROC_GSK_JOB_CACHE_DB,
72 VPROC_GSK_EMBEDDEDROOTEQUIVALENT,
73 } vproc_gsk_t;
74
75 typedef unsigned int vproc_flags_t;
76 /* For _vproc_kickstart_by_label() -- instructs launchd to kickstart the job to stall before exec(2). */
77 #define VPROCFLAG_STALL_JOB_EXEC 1 << 1
78
79 vproc_t vprocmgr_lookup_vproc(const char *label);
80 vproc_t vproc_retain(vproc_t vp);
81 void vproc_release(vproc_t vp);
82
83 vproc_err_t vproc_swap_integer(vproc_t vp, vproc_gsk_t key, int64_t *inval, int64_t *outval);
84 vproc_err_t vproc_swap_complex(vproc_t vp, vproc_gsk_t key, launch_data_t inval, launch_data_t *outval);
85 vproc_err_t vproc_swap_string(vproc_t vp, vproc_gsk_t key, const char *instr, char **outstr);
86
87 vproc_err_t _vproc_get_last_exit_status(int *wstatus);
88 vproc_err_t _vproc_set_global_on_demand(bool val);
89
90 typedef void (*_vprocmgr_log_drain_callback_t)(struct timeval *when, pid_t from_pid, pid_t about_pid, uid_t sender_uid, gid_t sender_gid, int priority, const char *from_name, const char *about_name, const char *session_name, const char *msg);
91
92 vproc_err_t _vprocmgr_log_drain(vproc_t vp, pthread_mutex_t *optional_mutex_around_callback, _vprocmgr_log_drain_callback_t func);
93
94 vproc_err_t _vproc_send_signal_by_label(const char *label, int sig);
95 vproc_err_t _vproc_kickstart_by_label(const char *label, pid_t *out_pid, mach_port_t *out_port_name, mach_port_t *out_obsrvr_port, vproc_flags_t flags);
96 vproc_err_t _vproc_wait_by_label(const char *label, int *out_wstatus);
97
98 void _vproc_log(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3)));
99 void _vproc_log_error(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3)));
100 void _vproc_logv(int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 3, 0)));
101
102 #define VPROCMGR_SESSION_LOGINWINDOW "LoginWindow"
103 #define VPROCMGR_SESSION_BACKGROUND "Background"
104 #define VPROCMGR_SESSION_AQUA "Aqua"
105 #define VPROCMGR_SESSION_STANDARDIO "StandardIO"
106 #define VPROCMGR_SESSION_SYSTEM "System"
107
108 vproc_err_t _vprocmgr_move_subset_to_user(uid_t target_user, const char *session_type, uint64_t flags);
109 vproc_err_t _vprocmgr_switch_to_session(const char *target_session, vproc_flags_t flags);
110 vproc_err_t _vprocmgr_detach_from_console(vproc_flags_t flags);
111
112 void _vproc_standby_begin(void) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
113 void _vproc_standby_end(void) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
114 size_t _vproc_standby_count(void) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
115 size_t _vproc_standby_timeout(void) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
116
117 kern_return_t _vproc_transaction_count_for_pid(pid_t p, int32_t *count, bool *condemned) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
118 bool _vproc_pid_is_managed(pid_t p) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
119 void _vproc_transaction_try_exit(int status) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
120 void _vproc_transaction_begin(void) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
121 void _vproc_transaction_end(void) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
122 size_t _vproc_transaction_count(void) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
123
124 #pragma GCC visibility pop
125
126 __END_DECLS
127
128 #endif