]>
git.saurik.com Git - apple/launchd.git/blob - launchd/src/launch_priv.h
2 * Copyright (c) 2005 Apple Computer, 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@
20 #ifndef _LAUNCH_PRIV_H_
21 #define _LAUNCH_PRIV_H_
23 #include <mach/mach.h>
24 #include <sys/types.h>
28 #include <uuid/uuid.h>
30 #pragma GCC visibility push(default)
34 #define LAUNCH_KEY_SETUSERENVIRONMENT "SetUserEnvironment"
35 #define LAUNCH_KEY_UNSETUSERENVIRONMENT "UnsetUserEnvironment"
36 #define LAUNCH_KEY_SHUTDOWN "Shutdown"
37 #define LAUNCH_KEY_SINGLEUSER "SingleUser"
38 #define LAUNCH_KEY_GETRESOURCELIMITS "GetResourceLimits"
39 #define LAUNCH_KEY_SETRESOURCELIMITS "SetResourceLimits"
40 #define LAUNCH_KEY_GETRUSAGESELF "GetResourceUsageSelf"
41 #define LAUNCH_KEY_GETRUSAGECHILDREN "GetResourceUsageChildren"
42 #define LAUNCH_KEY_SETPRIORITYLIST "SetPriorityList"
44 #define LAUNCHD_SOCKET_ENV "LAUNCHD_SOCKET"
45 #define LAUNCHD_SOCK_PREFIX _PATH_VARTMP "launchd"
46 #define LAUNCHD_TRUSTED_FD_ENV "__LAUNCHD_FD"
47 #define LAUNCHD_ASYNC_MSG_KEY "_AsyncMessage"
48 #define LAUNCH_KEY_BATCHCONTROL "BatchControl"
49 #define LAUNCH_KEY_BATCHQUERY "BatchQuery"
50 #define LAUNCHD_DO_APPLE_INTERNAL_LOGGING "__DoAppleInternalLogging__"
52 #define LAUNCH_JOBKEY_TRANSACTIONCOUNT "TransactionCount"
53 #define LAUNCH_JOBKEY_QUARANTINEDATA "QuarantineData"
54 #define LAUNCH_JOBKEY_SANDBOXPROFILE "SandboxProfile"
55 #define LAUNCH_JOBKEY_SANDBOXFLAGS "SandboxFlags"
56 #define LAUNCH_JOBKEY_SANDBOX_NAMED "Named"
57 #define LAUNCH_JOBKEY_JETSAMPROPERTIES "JetsamProperties"
58 #define LAUNCH_JOBKEY_JETSAMPRIORITY "JetsamPriority"
59 #define LAUNCH_JOBKEY_JETSAMMEMORYLIMIT "JetsamMemoryLimit"
60 #define LAUNCH_JOBKEY_SECURITYSESSIONUUID "SecuritySessionUUID"
62 #define LAUNCH_KEY_JETSAMLABEL "JetsamLabel"
63 #define LAUNCH_KEY_JETSAMFRONTMOST "JetsamFrontmost"
64 #define LAUNCH_KEY_JETSAMPRIORITY LAUNCH_JOBKEY_JETSAMPRIORITY
65 #define LAUNCH_KEY_JETSAMMEMORYLIMIT LAUNCH_JOBKEY_JETSAMMEMORYLIMIT
67 #define LAUNCH_JOBKEY_EMBEDDEDPRIVILEGEDISPENSATION "EmbeddedPrivilegeDispensation"
68 #define LAUNCH_JOBKEY_EMBEDDEDMAINTHREADPRIORITY "EmbeddedMainThreadPriority"
70 #define LAUNCH_JOBKEY_ENTERKERNELDEBUGGERBEFOREKILL "EnterKernelDebuggerBeforeKill"
71 #define LAUNCH_JOBKEY_PERJOBMACHSERVICES "PerJobMachServices"
72 #define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC"
73 #define LAUNCH_JOBKEY_BINARYORDERPREFERENCE "BinaryOrderPreference"
74 #define LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER "MachExceptionHandler"
76 #define LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer"
77 #define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer"
78 #define LAUNCH_JOBKEY_MACH_TASKSPECIALPORT "TaskSpecialPort"
79 #define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort"
80 #define LAUNCH_JOBKEY_MACH_ENTERKERNELDEBUGGERONCLOSE "EnterKernelDebuggerOnClose"
82 typedef struct _launch
*launch_t
;
84 launch_t
launchd_fdopen(int, int);
85 int launchd_getfd(launch_t
);
86 void launchd_close(launch_t
, __typeof__(close
) closefunc
);
88 launch_data_t
launch_data_new_errno(int);
89 bool launch_data_set_errno(launch_data_t
, int);
91 int launchd_msg_send(launch_t
, launch_data_t
);
92 int launchd_msg_recv(launch_t
, void (*)(launch_data_t
, void *), void *);
96 * After this call, the task's bootstrap port is set to the per session launchd.
98 * This returns 1 on success (it used to return otherwise), and -1 on failure.
100 #define LOAD_ONLY_SAFEMODE_LAUNCHAGENTS 1 << 0
101 #define LAUNCH_GLOBAL_ON_DEMAND 1 << 1
102 pid_t
create_and_switch_to_per_session_launchd(const char * /* loginname */, int flags
, ...);
104 /* Also for LoginWindow.
106 * This is will load jobs at the LoginWindow prompt.
108 void load_launchd_jobs_at_loginwindow_prompt(int flags
, ...);
111 /* batch jobs will be implicity re-enabled when the last application who
112 * disabled them exits.
114 * This API is really a hack to work around the lack of real-time APIs
117 void launchd_batch_enable(bool);
118 bool launchd_batch_query(void);
123 #define SPAWN_VIA_LAUNCHD_STOPPED 0x0001
125 struct spawn_via_launchd_attr
{
126 uint64_t spawn_flags
;
127 const char * spawn_path
;
128 const char * spawn_chdir
;
129 const char *const * spawn_env
;
130 const mode_t
* spawn_umask
;
131 mach_port_t
* spawn_observer_port
;
132 const cpu_type_t
* spawn_binpref
;
133 size_t spawn_binpref_cnt
;
134 void * spawn_quarantine
;
135 const char * spawn_seatbelt_profile
;
136 const uint64_t * spawn_seatbelt_flags
;
139 #define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 2)
140 pid_t
_spawn_via_launchd(
142 const char *const *argv
,
143 const struct spawn_via_launchd_attr
*spawn_attrs
,
146 kern_return_t
mpm_wait(mach_port_t ajob
, int *wstatus
);
148 kern_return_t
mpm_uncork_fork(mach_port_t ajob
);
153 #pragma GCC visibility pop