Skip to main content

ohos_abilitykit_sys/childprocess/
childprocess_ffi.rs

1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6use ohos_sys_opaque_types::OHIPCRemoteProxy;
7
8pub type Ability_NativeChildProcessResult = Result<(), Ability_NativeChildProcessErrorCode>;
9#[cfg(feature = "api-12")]
10#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
11impl Ability_NativeChildProcessErrorCode {
12    /// Invalid parameter.
13    pub const INVALID_PARAM: Ability_NativeChildProcessErrorCode =
14        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(401).unwrap() });
15    /// Creating a native child process is not supported.
16    pub const NOT_SUPPORTED: Ability_NativeChildProcessErrorCode =
17        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(801).unwrap() });
18    /// Internal error.
19    pub const INTERNAL: Ability_NativeChildProcessErrorCode =
20        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16000050).unwrap() });
21    /// A new child process cannot be created during the startup of another native child process.
22    /// You can try again after the child process is started.
23    pub const BUSY: Ability_NativeChildProcessErrorCode =
24        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010001).unwrap() });
25    /// Starting the native child process times out.
26    pub const TIMEOUT: Ability_NativeChildProcessErrorCode =
27        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010002).unwrap() });
28    /// Server error.
29    pub const SERVICE_ERROR: Ability_NativeChildProcessErrorCode =
30        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010003).unwrap() });
31    /// The multi-process mode is disabled. A child process cannot be started.
32    pub const MULTI_PROCESS_DISABLED: Ability_NativeChildProcessErrorCode =
33        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010004).unwrap() });
34    /// A process cannot be created in a child process.
35    pub const ALREADY_IN_CHILD: Ability_NativeChildProcessErrorCode =
36        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010005).unwrap() });
37    /// The number of native child processes reaches the maximum.
38    pub const MAX_CHILD_PROCESSES_REACHED: Ability_NativeChildProcessErrorCode =
39        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010006).unwrap() });
40    /// The child process fails to load the dynamic library because the file does not exist
41    /// or the corresponding method is not implemented or exported.
42    pub const LIB_LOADING_FAILED: Ability_NativeChildProcessErrorCode =
43        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010007).unwrap() });
44    /// The child process fails to call the OnConnect method of the dynamic library.
45    /// An invalid IPC object pointer may be returned.
46    pub const CONNECTION_FAILED: Ability_NativeChildProcessErrorCode =
47        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010008).unwrap() });
48    /// The callback does not exist; it may not have been registered or has already been unregistered.
49    ///
50    /// Available since API-level: 20
51    #[cfg(feature = "api-20")]
52    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
53    pub const CALLBACK_NOT_EXIST: Ability_NativeChildProcessErrorCode =
54        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010009).unwrap() });
55    /// The specified PID does not exist or is not a child process of the current process
56    /// or is a SELF_FORK mode child process.
57    ///
58    /// Available since API-level: 22
59    #[cfg(feature = "api-22")]
60    #[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
61    pub const INVALID_PID: Ability_NativeChildProcessErrorCode =
62        Ability_NativeChildProcessErrorCode(const { core::num::NonZero::new(16010010).unwrap() });
63}
64#[repr(transparent)]
65/// Enumerates the error codes used by the native child process module.
66///
67/// Available since API-level: 12
68#[cfg(feature = "api-12")]
69#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
70#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
71pub struct Ability_NativeChildProcessErrorCode(pub core::num::NonZero<::core::ffi::c_uint>);
72#[cfg(feature = "api-13")]
73#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
74impl NativeChildProcess_IsolationMode {
75    /// Normal isolation mode, parent process shares the same sandbox or internet with the child process.
76    pub const NCP_ISOLATION_MODE_NORMAL: NativeChildProcess_IsolationMode =
77        NativeChildProcess_IsolationMode(0);
78    /// Isolated mode, parent process does not share the same sandbox or internet with the child process.
79    pub const NCP_ISOLATION_MODE_ISOLATED: NativeChildProcess_IsolationMode =
80        NativeChildProcess_IsolationMode(1);
81}
82#[repr(transparent)]
83/// Enumerates the isolation modes used by the native child process module.
84///
85/// Available since API-level: 13
86#[cfg(feature = "api-13")]
87#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
88#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
89pub struct NativeChildProcess_IsolationMode(pub ::core::ffi::c_uint);
90/// Defines a struct for the child process configs.
91///
92/// Available since API-level: 20
93#[cfg(feature = "api-20")]
94#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
95#[repr(C)]
96pub struct Ability_ChildProcessConfigs {
97    _unused: [u8; 0],
98}
99/// Defines a callback function for notifying the child process startup result.
100///
101/// # Arguments
102///
103/// * `errCode` - Error code corresponding to the callback function. The following values are available:
104/// [`NCP_NO_ERROR`] if the child process is created successfully.
105///
106/// [`NCP_ERR_LIB_LOADING_FAILED`] if loading the dynamic library file fails or the necessary export function
107/// is not implemented in the dynamic library.
108///
109/// [`NCP_ERR_CONNECTION_FAILED`] if the OnConnect method implemented in the dynamic library does not return
110/// a valid IPC stub pointer.
111///
112/// For details, see [`Ability_NativeChildProcess_ErrCode`].
113///
114/// * `remoteProxy` - Pointer to the IPC object of the child process. If an exception occurs, the value may be nullptr.
115/// The object must be released by calling [`OH_IPCRemoteProxy_Destory`] when it is no longer needed.
116/// [`OH_Ability_CreateNativeChildProcess`] [`OH_IPCRemoteProxy_Destory`]
117/// Available since API-level: 12
118#[cfg(feature = "api-12")]
119#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
120pub type OH_Ability_OnNativeChildProcessStarted = ::core::option::Option<
121    unsafe extern "C" fn(errCode: ::core::ffi::c_int, remoteProxy: *mut OHIPCRemoteProxy),
122>;
123/// The info of the file descriptors passed to child process.
124///
125/// Available since API-level: 13
126#[cfg(feature = "api-13")]
127#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
128#[repr(C)]
129#[derive(Debug, Copy, Clone)]
130pub struct NativeChildProcess_Fd {
131    /// the key of the file descriptor.
132    pub fdName: *mut ::core::ffi::c_char,
133    /// the value of the file descriptor.
134    pub fd: i32,
135    /// the next pointer of the linked list.
136    pub next: *mut NativeChildProcess_Fd,
137}
138/// The list of the info of the file descriptors passed to child process.
139///
140/// Available since API-level: 13
141#[cfg(feature = "api-13")]
142#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
143#[repr(C)]
144#[derive(Debug, Copy, Clone)]
145pub struct NativeChildProcess_FdList {
146    /// the head of the list.
147    /// For details, see [`NativeChildProcess_Fd`].
148    pub head: *mut NativeChildProcess_Fd,
149}
150/// The options used by the child process.
151///
152/// Available since API-level: 13
153#[cfg(feature = "api-13")]
154#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
155#[repr(C)]
156#[derive(Debug, Copy, Clone)]
157pub struct NativeChildProcess_Options {
158    /// the isolation mode used by the child process.
159    /// For details, see [`NativeChildProcess_IsolationMode`].
160    pub isolationMode: NativeChildProcess_IsolationMode,
161    /// reserved field for future extension purposes
162    pub reserved: i64,
163}
164/// The arguments passed to the child process.
165///
166/// Available since API-level: 13
167#[cfg(feature = "api-13")]
168#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
169#[repr(C)]
170#[derive(Debug, Copy, Clone)]
171pub struct NativeChildProcess_Args {
172    /// the entry parameter.
173    pub entryParams: *mut ::core::ffi::c_char,
174    /// the list of the info of the file descriptors passed to child process.
175    /// For details, see [`NativeChildProcess_FdList`].
176    pub fdList: NativeChildProcess_FdList,
177}
178/// Defines a callback function to handle the exit of a native child process.
179///
180/// # Arguments
181///
182/// * `pid` - The pid of the exited native child process.
183///
184/// * `signal` - The signal of the exited native child process.
185///
186/// Available since API-level: 20
187#[cfg(feature = "api-20")]
188#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
189pub type OH_Ability_OnNativeChildProcessExit =
190    ::core::option::Option<unsafe extern "C" fn(pid: i32, signal: i32)>;
191extern "C" {
192    /// Creates a new child process configs object.
193    /// The caller is responsible for destroying the returned object by calling
194    /// [`OH_Ability_DestroyChildProcessConfigs`] to avoid memory leaks.
195    ///
196    /// # Returns
197    ///
198    /// * Returns a pointer to the newly created [`Ability_ChildProcessConfigs`] object if successful.
199    /// Returns nullptr if an internal error occurs or memory allocation fails.
200    ///
201    /// Available since API-level: 20
202    #[cfg(feature = "api-20")]
203    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
204    pub fn OH_Ability_CreateChildProcessConfigs() -> *mut Ability_ChildProcessConfigs;
205    /// Destroys a child process configs object and releases associated resources.
206    ///
207    /// # Arguments
208    ///
209    /// * `configs` - Pointer to the child process configs object to be destroyed.
210    /// After this call, the pointer becomes invalid and must not be used.
211    /// Passing nullptr is allowed and will be ignored.
212    ///
213    /// # Returns
214    ///
215    /// * Returns [`NCP_NO_ERROR`] if the operation is successful or if the input is nullptr.
216    /// Returns [`NCP_ERR_INVALID_PARAM`] if the input parameters are invalid.
217    ///
218    /// Available since API-level: 20
219    #[cfg(feature = "api-20")]
220    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
221    pub fn OH_Ability_DestroyChildProcessConfigs(
222        configs: *mut Ability_ChildProcessConfigs,
223    ) -> Ability_NativeChildProcessResult;
224    /// Sets the isolation mode for the specified child process configs.
225    ///
226    /// # Arguments
227    ///
228    /// * `configs` - Pointer to the child process configs object. Must not be nullptr.
229    ///
230    /// * `isolationMode` - The isolation mode to set. See [`NativeChildProcess_IsolationMode`] for details.
231    ///
232    /// # Returns
233    ///
234    /// * Returns [`NCP_NO_ERROR`] if the isolation mode is set successfully.
235    /// Returns [`NCP_ERR_INVALID_PARAM`] if the input parameters are invalid.
236    ///
237    /// Available since API-level: 20
238    #[cfg(feature = "api-20")]
239    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
240    pub fn OH_Ability_ChildProcessConfigs_SetIsolationMode(
241        configs: *mut Ability_ChildProcessConfigs,
242        isolationMode: NativeChildProcess_IsolationMode,
243    ) -> Ability_NativeChildProcessResult;
244    /// Sets the UID isolation flag for the specified child process configs.
245    /// The isolationUid only takes effect when [`OH_Ability_ChildProcessConfigs_SetIsolationMode`]
246    /// is set to [`NCP_ISOLATION_MODE_ISOLATED`].
247    ///
248    /// # Arguments
249    ///
250    /// * `configs` - Pointer to the child process configs object. Must not be nullptr.
251    ///
252    /// * `isolationUid` - The UID isolation setting to apply.
253    /// - true: uses independent UID
254    /// - false: uses parent process's UID
255    ///
256    /// # Returns
257    ///
258    /// * Returns [`NCP_NO_ERROR`] if the UID isolation flag is set successfully.
259    /// Returns [`NCP_ERR_INVALID_PARAM`] if the input parameters are invalid.
260    ///
261    /// Available since API-level: 21
262    #[cfg(feature = "api-21")]
263    #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
264    pub fn OH_Ability_ChildProcessConfigs_SetIsolationUid(
265        configs: *mut Ability_ChildProcessConfigs,
266        isolationUid: bool,
267    ) -> Ability_NativeChildProcessResult;
268    /// Sets the process name for the specified child process configs.
269    ///
270    /// # Arguments
271    ///
272    /// * `configs` - Pointer to the child process configs object. Must not be nullptr.
273    ///
274    /// * `processName` - The process name to set.
275    /// Must be a non-empty string containing only letters, digits, or underscores.
276    /// Maximum length is 64 characters.
277    /// The name ultimately assigned to the process is {bundleName}:{processName}.
278    ///
279    /// # Returns
280    ///
281    /// * Returns [`NCP_NO_ERROR`] if the process name is set successfully.
282    /// Returns [`NCP_ERR_INVALID_PARAM`] if the input parameters are invalid.
283    ///
284    /// Available since API-level: 20
285    #[cfg(feature = "api-20")]
286    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
287    pub fn OH_Ability_ChildProcessConfigs_SetProcessName(
288        configs: *mut Ability_ChildProcessConfigs,
289        processName: *const ::core::ffi::c_char,
290    ) -> Ability_NativeChildProcessResult;
291    /// Creates a child process, loads the specified dynamic library file, and returns the startup result
292    /// asynchronously through a callback parameter.
293    /// The callback notification is an independent thread. When implementing the callback function,
294    /// pay attention to thread synchronization and do not perform time-consuming operations to avoid long-time blocking.
295    ///
296    /// The dynamic library specified must implement and export the following functions:
297    ///
298    /// 1. OHIPCRemoteStub* NativeChildProcess_OnConnect()
299    ///
300    /// 2. void NativeChildProcess_MainProc()
301    ///
302    ///
303    /// The processing logic sequence is shown in the following pseudocode:
304    ///
305    /// Main process:
306    ///
307    /// 1. OH_Ability_CreateNativeChildProcess(libName, onProcessStartedCallback)
308    ///
309    /// Child process:
310    ///
311    /// 2. dlopen(libName)
312    ///
313    /// 3. dlsym("NativeChildProcess_OnConnect")
314    ///
315    /// 4. dlsym("NativeChildProcess_MainProc")
316    ///
317    /// 5. ipcRemote = NativeChildProcess_OnConnect()
318    ///
319    /// 6. NativeChildProcess_MainProc()
320    ///
321    /// Main process:
322    ///
323    /// 7. onProcessStartedCallback(ipcRemote, errCode)
324    ///
325    /// Child process:
326    ///
327    /// 8. The child process exits after the NativeChildProcess_MainProc() function is returned.
328    ///
329    ///
330    /// # Arguments
331    ///
332    /// * `libName` - Name of the dynamic library file loaded in the child process. The value cannot be nullptr.
333    ///
334    /// * `onProcessStarted` - Pointer to the callback function for notifying the child process startup result.
335    /// The value cannot be nullptr. For details, see [`OH_Ability_OnNativeChildProcessStarted`].
336    ///
337    /// # Returns
338    ///
339    /// * Returns [`NCP_NO_ERROR`] if the call is successful, but the actual startup result is notified by the
340    /// callback function.
341    ///
342    /// Returns [`NCP_ERR_INVALID_PARAM`] if the dynamic library name or callback function pointer is invalid.
343    ///
344    /// Returns [`NCP_ERR_NOT_SUPPORTED`] if the device does not support the creation of native child processes.
345    ///
346    /// Returns [`NCP_ERR_MULTI_PROCESS_DISABLED`] if the multi-process mode is disabled on the device.
347    ///
348    /// Returns [`NCP_ERR_ALREADY_IN_CHILD`] if it is not allowed to create another child process in the child process.
349    ///
350    /// Returns [`NCP_ERR_MAX_CHILD_PROCESSES_REACHED`] if the maximum number of native child processes is reached.
351    ///
352    /// For details, see [`Ability_NativeChildProcess_ErrCode`].
353    /// [`OH_Ability_OnNativeChildProcessStarted`]
354    /// Available since API-level: 12
355    #[cfg(feature = "api-12")]
356    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
357    pub fn OH_Ability_CreateNativeChildProcess(
358        libName: *const ::core::ffi::c_char,
359        onProcessStarted: OH_Ability_OnNativeChildProcessStarted,
360    ) -> ::core::ffi::c_int;
361    /// Creates a child process, loads the specified dynamic library file, and returns the startup result
362    /// asynchronously through a callback parameter.
363    /// The callback notification is an independent thread. When implementing the callback function,
364    /// pay attention to thread synchronization and do not perform time-consuming operations to avoid long-time blocking.
365    ///
366    /// The dynamic library specified must implement and export the following functions:
367    /// 1. OHIPCRemoteStub* NativeChildProcess_OnConnect()
368    /// 2. void NativeChildProcess_MainProc()
369    ///
370    /// The processing logic sequence is shown in the following pseudocode:
371    /// Main process:
372    /// 1. OH_Ability_CreateNativeChildProcessWithConfigs(libName, configs, onProcessStartedCallback)
373    /// Child process:
374    /// 2. dlopen(libName)
375    /// 3. dlsym("NativeChildProcess_OnConnect")
376    /// 4. dlsym("NativeChildProcess_MainProc")
377    /// 5. ipcRemote = NativeChildProcess_OnConnect()
378    /// 6. NativeChildProcess_MainProc()
379    /// Main process:
380    /// 7. onProcessStartedCallback(ipcRemote, errCode)
381    /// Child process:
382    /// 8. The child process exits after the NativeChildProcess_MainProc() function is returned.
383    ///
384    /// # Arguments
385    ///
386    /// * `libName` - Name of the dynamic library file loaded in the child process. The value cannot be nullptr.
387    ///
388    /// * `configs` - Pointer to the child process configs object. The value cannot be nullptr.
389    ///
390    /// * `onProcessStarted` - Pointer to the callback function for notifying the child process startup result.
391    /// The value cannot be nullptr. For details, see [`OH_Ability_OnNativeChildProcessStarted`].
392    ///
393    /// # Returns
394    ///
395    /// * Returns [`NCP_NO_ERROR`] if the call is successful, but the actual startup result is notified by the
396    /// callback function.
397    /// Returns [`NCP_ERR_INVALID_PARAM`] if the dynamic library name or callback function pointer is invalid.
398    /// Returns [`NCP_ERR_NOT_SUPPORTED`] if the device does not support the creation of native child processes.
399    /// Returns [`NCP_ERR_MULTI_PROCESS_DISABLED`] if the multi-process mode is disabled on the device.
400    /// Returns [`NCP_ERR_ALREADY_IN_CHILD`] if it is not allowed to create another child process in the child process.
401    /// Returns [`NCP_ERR_MAX_CHILD_PROCESSES_REACHED`] if the maximum number of native child processes is reached.
402    /// For details, see [`Ability_NativeChildProcess_ErrCode`].
403    /// [`OH_Ability_OnNativeChildProcessStarted`]
404    /// Available since API-level: 20
405    #[cfg(feature = "api-20")]
406    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
407    pub fn OH_Ability_CreateNativeChildProcessWithConfigs(
408        libName: *const ::core::ffi::c_char,
409        configs: *mut Ability_ChildProcessConfigs,
410        onProcessStarted: OH_Ability_OnNativeChildProcessStarted,
411    ) -> Ability_NativeChildProcessResult;
412    /// Starts a child process, loads the specified dynamic library file.
413    ///
414    /// The dynamic library specified must implement a function with NativeChildProcess_Args as a
415    /// pamameter(function name can be customized), and export the function, such as:
416    ///
417    /// 1. void Main(NativeChildProcess_Args args);
418    ///
419    /// The processing logic sequence is shown in the following pseudocode:
420    ///
421    /// Main process:
422    ///
423    /// 1. OH_Ability_StartNativeChildProcess(entryPoint, args, options)
424    ///
425    /// Child process:
426    ///
427    /// 2. dlopen(libName)
428    ///
429    /// 3. dlsym("Main")
430    ///
431    /// 4. Main(args)
432    ///
433    /// 5. The child process exits after the Main(args) function is returned
434    ///
435    ///
436    /// # Arguments
437    ///
438    /// * `entry` - Dynamic library and entry function loaded in child process, such as "libEntry.so:Main".
439    /// The value cannot be nullptr.
440    ///
441    /// * `args` - The arguments passed to the child process.
442    /// For details, see [`NativeChildProcess_Args`].
443    ///
444    /// * `options` - The child process options.
445    /// For details, see [`NativeChildProcess_Options`].
446    ///
447    /// * `pid` - The started child process id.
448    ///
449    /// # Returns
450    ///
451    /// * Returns [`NCP_NO_ERROR`] if the call is successful.
452    ///
453    /// Returns [`NCP_ERR_INVALID_PARAM`] if the dynamic library name or callback function pointer is invalid.
454    ///
455    /// Returns [`NCP_ERR_NOT_SUPPORTED`] if the device does not support the creation of native child processes.
456    ///
457    /// Returns [`NCP_ERR_ALREADY_IN_CHILD`] if it is not allowed to create another child process in the child process.
458    ///
459    /// Returns [`NCP_ERR_MAX_CHILD_PROCESSES_REACHED`] if the maximum number of native child processes is reached.
460    ///
461    /// For details, see [`Ability_NativeChildProcess_ErrCode`].
462    /// [`OH_Ability_OnNativeChildProcessStarted`]
463    /// Available since API-level: 13
464    #[cfg(feature = "api-13")]
465    #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
466    pub fn OH_Ability_StartNativeChildProcess(
467        entry: *const ::core::ffi::c_char,
468        args: NativeChildProcess_Args,
469        options: NativeChildProcess_Options,
470        pid: *mut i32,
471    ) -> Ability_NativeChildProcessResult;
472    /// Starts a child process, loads the specified dynamic library file.
473    ///
474    /// The dynamic library specified must implement a function with NativeChildProcess_Args as a
475    /// pamameter(function name can be customized), and export the function, such as:
476    /// 1. void Main(NativeChildProcess_Args args);
477    ///
478    /// The processing logic sequence is shown in the following pseudocode:
479    /// Main process:
480    /// 1. OH_Ability_StartNativeChildProcessWithConfigs(entryPoint, args, configs, &pid)
481    /// Child process:
482    /// 2. dlopen(libName)
483    /// 3. dlsym("Main")
484    /// 4. Main(args)
485    /// 5. The child process exits after the Main(args) function is returned
486    ///
487    /// # Arguments
488    ///
489    /// * `entry` - Dynamic library and entry function loaded in child process, such as "libEntry.so:Main".
490    /// The value cannot be nullptr.
491    ///
492    /// * `args` - The arguments passed to the child process.
493    /// For details, see [`NativeChildProcess_Args`].
494    ///
495    /// * `configs` - Pointer to the child process configs object. The value cannot be null.
496    /// For details, see [`Ability_ChildProcessConfigs`].
497    ///
498    /// * `pid` - The started child process id.
499    ///
500    /// # Returns
501    ///
502    /// * Returns [`NCP_NO_ERROR`] if the call is successful.
503    /// Returns [`NCP_ERR_INVALID_PARAM`] if the dynamic library name or callback function pointer is invalid.
504    /// Returns [`NCP_ERR_NOT_SUPPORTED`] if the device does not support the creation of native child processes.
505    /// Returns [`NCP_ERR_ALREADY_IN_CHILD`] if it is not allowed to create another child process in the child process.
506    /// Returns [`NCP_ERR_MAX_CHILD_PROCESSES_REACHED`] if the maximum number of native child processes is reached.
507    /// For details, see [`Ability_NativeChildProcess_ErrCode`].
508    ///
509    /// Available since API-level: 20
510    #[cfg(feature = "api-20")]
511    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
512    pub fn OH_Ability_StartNativeChildProcessWithConfigs(
513        entry: *const ::core::ffi::c_char,
514        args: NativeChildProcess_Args,
515        configs: *mut Ability_ChildProcessConfigs,
516        pid: *mut i32,
517    ) -> Ability_NativeChildProcessResult;
518    /// Child process get self NativeChildProcess_Args.
519    ///
520    ///
521    /// # Returns
522    ///
523    /// * Returns a pointer to the arguments passed to current child process.
524    ///
525    /// For details, see [`NativeChildProcess_Args`].
526    ///
527    /// Available since API-level: 17
528    #[cfg(feature = "api-17")]
529    #[cfg_attr(docsrs, doc(cfg(feature = "api-17")))]
530    pub fn OH_Ability_GetCurrentChildProcessArgs() -> *mut NativeChildProcess_Args;
531    /// Register a native child process exit callback.
532    /// Registering the same callback repeatedly will only keep one.
533    ///
534    /// # Arguments
535    ///
536    /// * `onProcessExit` - Pointer to the callback function to handle the exit of a native child process.
537    /// For details, see [`OH_Ability_OnNativeChildProcessExit`].
538    ///
539    /// # Returns
540    ///
541    /// * Returns [`NCP_NO_ERROR`] if the call is successful.
542    /// Returns [`NCP_ERR_INTERNAL`] if internal error occurs.
543    /// For details, see [`Ability_NativeChildProcess_ErrCode`].
544    ///
545    /// Available since API-level: 20
546    #[cfg(feature = "api-20")]
547    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
548    pub fn OH_Ability_RegisterNativeChildProcessExitCallback(
549        onProcessExit: OH_Ability_OnNativeChildProcessExit,
550    ) -> Ability_NativeChildProcessResult;
551    /// Unregister a native child process exit callback.
552    ///
553    /// # Arguments
554    ///
555    /// * `onProcessExit` - Pointer to the callback function to handle the exit of a native child process.
556    /// For details, see [`OH_Ability_OnNativeChildProcessExit`].
557    ///
558    /// # Returns
559    ///
560    /// * Returns [`NCP_NO_ERROR`] if the call is successful.
561    /// Returns [`NCP_ERR_INTERNAL`] if internal error occurs.
562    /// Returns [`NCP_ERR_CALLBACK_NOT_EXIST`] if the callback is not exist.
563    /// For details, see [`Ability_NativeChildProcess_ErrCode`].
564    ///
565    /// Available since API-level: 20
566    #[cfg(feature = "api-20")]
567    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
568    pub fn OH_Ability_UnregisterNativeChildProcessExitCallback(
569        onProcessExit: OH_Ability_OnNativeChildProcessExit,
570    ) -> Ability_NativeChildProcessResult;
571    /// Terminates a child process created by the current process.
572    ///
573    /// <p>**NOTE**:
574    /// <br>Child processes created in SELF_FORK mode cannot be terminated.
575    /// </p>
576    ///
577    /// # Arguments
578    ///
579    /// * `pid` - Process ID of the target child process to terminate.
580    ///
581    /// # Returns
582    ///
583    /// * Returns [`NCP_NO_ERROR`] if the operation succeeds.
584    /// Returns [`NCP_ERR_SERVICE_ERROR`] if system service error occurs, please try again later.
585    /// Returns [`NCP_ERR_INVALID_PID`] if:
586    /// - The specified PID does not exist
587    /// - The PID is not a child process of the current process
588    /// - The PID is a SELF_FORK mode child process
589    /// For details, see [`Ability_NativeChildProcess_ErrCode`].
590    ///
591    /// Available since API-level: 22
592    #[cfg(feature = "api-22")]
593    #[cfg_attr(docsrs, doc(cfg(feature = "api-22")))]
594    pub fn OH_Ability_KillChildProcess(pid: i32) -> Ability_NativeChildProcessResult;
595}