Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/openlaunchd
Path: blob/master/liblaunch/vproc.h
374 views
1
/*
2
* Copyright (c) 2006 Apple Computer, 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_H__
22
#define __VPROC_H__
23
24
#include <sys/cdefs.h>
25
#include <sys/types.h>
26
#include <stdarg.h>
27
#ifdef __APPLE__
28
#include <Availability.h>
29
#else
30
#include "shims/Availability.h"
31
#endif
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
typedef void * vproc_err_t;
42
43
typedef struct vproc_s * vproc_t;
44
typedef void * vprocmgr_t;
45
46
const char *vproc_strerror(vproc_err_t r);
47
48
/*!
49
* @header vproc
50
*
51
* Processes have two reference counts associated with them:
52
*
53
* Transactions Tracks unfinished work. For example: saving a modified
54
* document.
55
* Standby Tracks outstanding callbacks from external subsystems.
56
*
57
* Descriptive aliases:
58
*
59
* A process with no outstanding transactions is called "clean."
60
* A process with outstanding transactions is called "dirty."
61
* A process with no standby work is called "idle."
62
*
63
* Sometimes, the operating system needs processes to exit. Unix has two
64
* primary signals to kill applications:
65
*
66
* SIGKILL Not catchable by the application.
67
* SIGTERM Catchable by the application.
68
*
69
* If a process is clean, the operating system is free to SIGKILL it at
70
* shutdown or logout. This behavior is opt in.
71
*
72
* If a process is clean and idle, the operating system may send SIGKILL after
73
* a application specified timeout. This behavior is opt in.
74
*
75
* If a process is dirty and idle, the operating system may send SIGTERM after
76
* a application specified timeout. This behavior is opt in.
77
*
78
*
79
* launchd jobs should update their property lists accordingly.
80
*
81
* We plan to have LaunchServices use private methods to coordinate
82
* whether GUI applications have opted into this design.
83
*/
84
85
/*!
86
* @typedef vproc_transaction_t
87
*
88
* @abstract
89
* An opaque handle used to track outstanding transactions.
90
*/
91
typedef struct vproc_transaction_s *vproc_transaction_t;
92
93
/*!
94
* @function vproc_transaction_begin
95
*
96
* @param virtual_proc
97
* This is meant for future API improvements. Pass NULL for now.
98
*
99
* @result
100
* Returns an opaque handle to be passed to vproc_transaction_end().
101
*
102
* @abstract
103
* Call this API before creating data that needs to be saved via I/O later.
104
*/
105
vproc_transaction_t
106
vproc_transaction_begin(vproc_t virtual_proc) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0);
107
108
/*!
109
* @function vproc_transaction_end
110
*
111
* @param virtual_proc
112
* This is meant for future API improvements. Pass NULL for now.
113
*
114
* @param handle
115
* The handle previously created with vproc_transaction_begin().
116
*
117
* @abstract
118
* Call this API after the data has either been flushed or otherwise resolved.
119
*
120
* @discussion
121
* Calling this API with the same handle more than once is undefined.
122
*/
123
void
124
vproc_transaction_end(vproc_t virtual_proc, vproc_transaction_t handle) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0);
125
126
/*!
127
* @typedef vproc_standby_t
128
*
129
* @abstract
130
* An opaque handle used to track outstanding standby requests.
131
*/
132
typedef struct vproc_standby_s *vproc_standby_t;
133
134
/*!
135
* @function vproc_standby_begin
136
*
137
* @param virtual_proc
138
* This is meant for future API improvements. Pass NULL for now.
139
*
140
* @result
141
* Returns an opaque handle to be passed to vproc_standby_end().
142
*
143
* @abstract
144
* Call this API before registering notifications. For example: timers network
145
* state change, or when monitoring keyboard/mouse events.
146
*
147
* @discussion
148
* This API is undefined and is currently a no-op.
149
*/
150
vproc_standby_t
151
vproc_standby_begin(vproc_t virtual_proc) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_NA);
152
153
/*!
154
* @function vproc_standby_end
155
*
156
* @param virtual_proc
157
* This is meant for future API improvements. Pass NULL for now.
158
*
159
* @param handle
160
* The handle previously created with vproc_standby_begin().
161
*
162
* @abstract
163
* Call this API when deregistering notifications.
164
*
165
* @discussion
166
* Calling this API with the same handle more than once is undefined.
167
* This API is undefined and is currently a no-op.
168
*/
169
void
170
vproc_standby_end(vproc_t virtual_proc, vproc_standby_t handle) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_NA);
171
172
#pragma GCC visibility pop
173
174
__END_DECLS
175
176
#endif /* __VPROC_H__ */
177
178