1e41f4b71Sopenharmony_ci# native_child_process.h 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Overview 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciThe **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. A maximum of 512 child processes can be started through this module and [childProcessManager](js-apis-app-ability-childProcessManager.md) (non-SELF_FORK mode). 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci**Library**: libchild_process.so 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci**Since**: 12 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci**Related module**: [ChildProcess](c-apis-ability-childprocess.md) 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## Summary 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci### Files 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci| Name | Description | 22e41f4b71Sopenharmony_ci| ------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | 23e41f4b71Sopenharmony_ci| [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| 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci### Types 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci| Name | Description | 28e41f4b71Sopenharmony_ci| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- | 29e41f4b71Sopenharmony_ci| 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.| 30e41f4b71Sopenharmony_ci| 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.| 31e41f4b71Sopenharmony_ci| typedef struct [NativeChildProcess_Fd](c-apis-ability-childprocess.md#nativechildprocess_fd) | Defines a struct for the file descriptor of a child process.| 32e41f4b71Sopenharmony_ci| typedef struct [NativeChildProcess_FdList](c-apis-ability-childprocess.md#nativechildprocess_fdlist) | Defines a struct for the linked list of file descriptors of a child process.| 33e41f4b71Sopenharmony_ci| typedef struct [NativeChildProcess_Args](c-apis-ability-childprocess.md#nativechildprocess_args) | Defines a struct for the arguments used for starting a child process.| 34e41f4b71Sopenharmony_ci| typedef struct [NativeChildProcess_Options](c-apis-ability-childprocess.md#nativechildprocess_options) | Defines a struct for the startup configuration options of a child process.| 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci### Enums 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci| Name | Description | 40e41f4b71Sopenharmony_ci| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | 41e41f4b71Sopenharmony_ci| [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.| 42e41f4b71Sopenharmony_ci| [NativeChildProcess_IsolationMode](c-apis-ability-childprocess.md#nativechildprocess_isolationmode) {<br> NCP_ISOLATION_MODE_NORMAL = 0,<br> NCP_ISOLATION_MODE_ISOLATED = 1,<br>} | Enumerates the isolation modes of a child process.| 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci### Functions 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci| Name | Description | 48e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | ------------------------------------------------------------ | 49e41f4b71Sopenharmony_ci| 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.<br><b>NOTE</b><br/>Currently, this function is valid only for 2-in-1 devices, and a process can start only one native child process by using this function. | 50e41f4b71Sopenharmony_ci| [Ability_NativeChildProcess_ErrCode](c-apis-ability-childprocess.md#ability_nativechildprocess_errcode) [OH_Ability_StartNativeChildProcess](c-apis-ability-childprocess.md#oh_ability_startnativechildprocess)(const char\* entry, [NativeChildProcess_Args](c-apis-ability-childprocess.md#nativechildprocess_args) args, [NativeChildProcess_Options](c-apis-ability-childprocess.md#nativechildprocess_options) options, int32_t *pid) | Starts a child process, loads the specified dynamic library file, and calls the entry function. Arguments can be passed to the child process.<br><b>NOTE</b><br/>Currently, this function is valid only for 2-in-1 devices and tablets. | 51