• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# native_child_process.h
2
3
4## Overview
5
6The **native_child_process.h** file declares the APIs used to create a native child process and establish an IPC channel between the main process and child process.
7
8**Library**: libchild_process.so
9
10**System capability**: SystemCapability.Ability.AbilityRuntime.Core
11
12**Since**: 12
13
14**Related module**: [ChildProcess](c-apis-ability-childprocess.md)
15
16
17## Summary
18
19### Files
20
21| Name                                                    | Description                                                                                                |
22| ------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
23| [native_child_process.h](native__child__process_8h.md) | Declares the APIs used to create a native child process and establish an IPC channel between the main process and child process.<br>File to include: <AbilityKit/native_child_process.h><br>Library: libchild_process.so|
24
25### Types
26
27| Name                                                                                                                                                                            | Description               |
28| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- |
29| typedef enum Ability_NativeChildProcess_ErrCode [Ability_NativeChildProcess_ErrCode](c-apis-ability-childprocess.md#ability_nativechildprocess_errcode)                        | Defines an enum for the error codes used by the native child process module.|
30| typedef void(\* [OH_Ability_OnNativeChildProcessStarted](c-apis-ability-childprocess.md#oh_ability_onnativechildprocessstarted)) (int errCode, OHIPCRemoteProxy \*remoteProxy) | Defines a callback function for notifying the child process startup result.|
31
32
33### Enums
34
35| Name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Description               |
36| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
37| [Ability_NativeChildProcess_ErrCode](c-apis-ability-childprocess.md#ability_nativechildprocess_errcode) {<br>    NCP_NO_ERROR = 0,<br>    NCP_ERR_INVALID_PARAM = 401,<br>    NCP_ERR_NOT_SUPPORTED = 801,<br>    NCP_ERR_INTERNAL = 16000050,<br>    NCP_ERR_BUSY = 16010001,<br>    NCP_ERR_TIMEOUT = 16010002,<br>    NCP_ERR_SERVICE_ERROR = 16010003,<br>    NCP_ERR_MULTI_PROCESS_DISABLED = 16010004,<br>    NCP_ERR_ALREADY_IN_CHILD = 16010005,<br>    NCP_ERR_MAX_CHILD_PROCESSES_REACHED = 16010006,<br>    NCP_ERR_LIB_LOADING_FAILED = 16010007,<br>    NCP_ERR_CONNECTION_FAILED = 16010008<br>} | Enumerates the error codes used by the native child process module.|
38
39
40### Functions
41
42| Name                                                         | Description                                                  |
43| ------------------------------------------------------------ | ------------------------------------------------------------ |
44| int [OH_Ability_CreateNativeChildProcess](c-apis-ability-childprocess.md#oh_ability_createnativechildprocess) (const char \*libName, [OH_Ability_OnNativeChildProcessStarted](c-apis-ability-childprocess.md#oh_ability_onnativechildprocessstarted) onProcessStarted) | Creates a child process, loads the specified dynamic library file, and returns the startup result asynchronously through a callback parameter. The callback notification is an independent thread. When implementing the callback function, pay attention to thread synchronization and do not perform time-consuming operations to avoid long-time blocking. |
45
46> **NOTE**
47>
48> Currently, only 2-in-1 devices are supported, and only one native child process can be started for a process.