1e41f4b71Sopenharmony_ci# ChildProcess 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## 概述 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci提供子进程的管理能力,支持创建Native子进程并在父子进程间建立IPC通道,用于实现多进程应用开发。 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci创建的子进程不支持UI界面,也不支持Context相关的接口调用。通过此模块和[childProcessManager](js-apis-app-ability-childProcessManager.md)(非SELF_FORK模式)启动的子进程总数最大为512个。 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Ability.AbilityRuntime.Core 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci**起始版本:** 12 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## 汇总 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci### 文件 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci| 名称 | 描述 | 21e41f4b71Sopenharmony_ci| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | 22e41f4b71Sopenharmony_ci| [native_child_process.h](native__child__process_8h.md) | 支持创建Native子进程,并在父子进程间建立IPC通道。<br>引用文件:<AbilityKit/native_child_process.h><br>库:libchild_process.so<br> | 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci### 类型定义 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci| 名称 | 描述 | 27e41f4b71Sopenharmony_ci| ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- | 28e41f4b71Sopenharmony_ci| typedef enum Ability_NativeChildProcess_ErrCode [Ability_NativeChildProcess_ErrCode](#ability_nativechildprocess_errcode) | 定义Native子进程模块错误码。 | 29e41f4b71Sopenharmony_ci| typedef void(\* [OH_Ability_OnNativeChildProcessStarted](#oh_ability_onnativechildprocessstarted)) (int errCode, OHIPCRemoteProxy \*remoteProxy) | 定义通知子进程启动结果的回调函数。 | 30e41f4b71Sopenharmony_ci| typedef struct [NativeChildProcess_Fd](#nativechildprocess_fdlist) | 定义子进程文件描述符记录。 | 31e41f4b71Sopenharmony_ci| typedef struct [NativeChildProcess_FdList](#nativechildprocess_fdlist) | 定义子进程文件描述符记录链表。 | 32e41f4b71Sopenharmony_ci| typedef struct [NativeChildProcess_Args](#nativechildprocess_args) | 定义启动子进程入参。 | 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci### 枚举 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci| 名称 | 描述 | 38e41f4b71Sopenharmony_ci| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | 39e41f4b71Sopenharmony_ci| [Ability_NativeChildProcess_ErrCode](#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>} | 定义Native子进程模块错误码。 | 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci### 函数 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci| 名称 | 描述 | 45e41f4b71Sopenharmony_ci| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | 46e41f4b71Sopenharmony_ci| int [OH_Ability_CreateNativeChildProcess](#oh_ability_createnativechildprocess) (const char \*libName, [OH_Ability_OnNativeChildProcessStarted](#oh_ability_onnativechildprocessstarted) onProcessStarted) | 创建子进程并加载参数中指定的动态链接库文件,进程启动结果通过回调参数异步通知,需注意回调通知为独立线程,回调函数实现需要注意线程同步,且不能执行高耗时操作避免长时间阻塞。 | 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci> **说明:** 49e41f4b71Sopenharmony_ci> 50e41f4b71Sopenharmony_ci> 当前仅支持2in1设备,且单个进程只能启动一个Native子进程。 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci## 类型定义说明 53e41f4b71Sopenharmony_ci### OH_Ability_OnNativeChildProcessStarted 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci``` 56e41f4b71Sopenharmony_citypedef void (*OH_Ability_OnNativeChildProcessStarted)(int errCode, OHIPCRemoteProxy *remoteProxy) 57e41f4b71Sopenharmony_ci``` 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci**描述** 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci通知子进程启动结果的回调函数。 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci**起始版本:** 12 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci**参数:** 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci| 名称 | 描述 | 68e41f4b71Sopenharmony_ci| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 69e41f4b71Sopenharmony_ci| errCode | NCP_NO_ERROR - 创建子进程成功<br>NCP_ERR_LIB_LOADING_FAILED - 加载动态库文件失败或动态库中未实现必要的导出函数<br>NCP_ERR_CONNECTION_FAILED - 动态库中实现的OnConnect方法未返回有效的IPC Stub指针<br>详见[Ability_NativeChildProcess_ErrCode](#ability_nativechildprocess_errcode)定义。 | 70e41f4b71Sopenharmony_ci| remoteProxy | 子进程的IPC对象指针,出现异常时可能为nullptr; 使用完毕后需要调用[OH_IPCRemoteProxy_Destory](../apis-ipc-kit/_o_h_i_p_c_remote_object.md#oh_ipcremoteproxy_destroy)方法释放。 | 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**参见:** 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci[OH_Ability_CreateNativeChildProcess](#oh_ability_createnativechildprocess) 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci[OH_IPCRemoteProxy_Destory](../apis-ipc-kit/_o_h_i_p_c_remote_object.md#oh_ipcremoteproxy_destroy) 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci### NativeChildProcess_Fd 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci``` 81e41f4b71Sopenharmony_citypedef struct NativeChildProcess_Fd { 82e41f4b71Sopenharmony_ci char* fdName; 83e41f4b71Sopenharmony_ci int32_t fd; 84e41f4b71Sopenharmony_ci struct NativeChildProcess_Fd* next; 85e41f4b71Sopenharmony_ci} NativeChildProcess_Fd; 86e41f4b71Sopenharmony_ci``` 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci**描述** 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci子进程文件描述记录。 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci**起始版本:** 13 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci**参数:** 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci| 名称 | 描述 | 97e41f4b71Sopenharmony_ci| ----------- | ------------- | 98e41f4b71Sopenharmony_ci| fdName | 文件描述关键字。最大长度为20字符。 | 99e41f4b71Sopenharmony_ci| fd | 文件描述符句柄。| 100e41f4b71Sopenharmony_ci| next | 下一个文件描述记录指针。 | 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci### NativeChildProcess_FdList 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci``` 105e41f4b71Sopenharmony_citypedef struct NativeChildProcess_FdList { 106e41f4b71Sopenharmony_ci struct NativeChildProcess_Fd* head; 107e41f4b71Sopenharmony_ci} NativeChildProcess_FdList; 108e41f4b71Sopenharmony_ci``` 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci**描述** 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci子进程文件描述记录链表。文件描述符记录个数不能超过16个。 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci**起始版本:** 13 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**参数:** 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci| 名称 | 描述 | 119e41f4b71Sopenharmony_ci| ----------- | ------------- | 120e41f4b71Sopenharmony_ci| head | 子进程文件描述记录链表中的第一个记录,详见[NativeChildProcess_FdList](#nativechildprocess_fdlist)定义。 | 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci### NativeChildProcess_Args 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci``` 125e41f4b71Sopenharmony_citypedef struct NativeChildProcess_Args { 126e41f4b71Sopenharmony_ci char* entryParams; 127e41f4b71Sopenharmony_ci struct NativeChildProcess_FdList fdList; 128e41f4b71Sopenharmony_ci} NativeChildProcess_Args; 129e41f4b71Sopenharmony_ci``` 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci**描述** 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci启动子进程的入参。 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ci**起始版本:** 13 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci**参数:** 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci| 名称 | 描述 | 140e41f4b71Sopenharmony_ci| ----------- | ------------- | 141e41f4b71Sopenharmony_ci| entryParams | 入口参数,大小不能超过150KB。 | 142e41f4b71Sopenharmony_ci| fdList | 子进程文件描述记录链表,详见[NativeChildProcess_FdList](#nativechildprocess_fdlist)定义。 | 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci### NativeChildProcess_Options 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci``` 147e41f4b71Sopenharmony_citypedef struct NativeChildProcess_Options { 148e41f4b71Sopenharmony_ci NativeChildProcess_IsolationMode isolationMode; 149e41f4b71Sopenharmony_ci int64_t reserved; 150e41f4b71Sopenharmony_ci} NativeChildProcess_Options; 151e41f4b71Sopenharmony_ci``` 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci**描述** 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci启动子进程的配置选项。 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ci**起始版本:** 13 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci**参数:** 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci| 名称 | 描述 | 162e41f4b71Sopenharmony_ci| ----------- | ------------- | 163e41f4b71Sopenharmony_ci| isolationMode | 进程独立模式,详见[NativeChildProcess_IsolationMode](#nativechildprocess_isolationmode)定义。 | 164e41f4b71Sopenharmony_ci| reserved | 保留字段。| 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci## 枚举类型说明 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci### Ability_NativeChildProcess_ErrCode 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci``` 171e41f4b71Sopenharmony_cienum Ability_NativeChildProcess_ErrCode 172e41f4b71Sopenharmony_ci``` 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ci**描述** 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci定义Native子进程模块错误码。 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci**起始版本:** 12 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 181e41f4b71Sopenharmony_ci| ----------------------------------- | ----------------------------------------------- | 182e41f4b71Sopenharmony_ci| NCP_NO_ERROR | 操作成功。 | 183e41f4b71Sopenharmony_ci| NCP_ERR_INVALID_PARAM | 无效参数。 | 184e41f4b71Sopenharmony_ci| NCP_ERR_NOT_SUPPORTED | 不支持创建Native子进程。 | 185e41f4b71Sopenharmony_ci| NCP_ERR_INTERNAL | 内部错误。 | 186e41f4b71Sopenharmony_ci| NCP_ERR_BUSY | 在Native子进程的启动过程中不能再次创建新的子进程,可以等待当前子进程启动完成后再次尝试。 | 187e41f4b71Sopenharmony_ci| NCP_ERR_TIMEOUT | 启动Native子进程超时。 | 188e41f4b71Sopenharmony_ci| NCP_ERR_SERVICE_ERROR | 服务端出错。 | 189e41f4b71Sopenharmony_ci| NCP_ERR_MULTI_PROCESS_DISABLED | 多进程模式已关闭,不允许启动子进程。 | 190e41f4b71Sopenharmony_ci| NCP_ERR_ALREADY_IN_CHILD | 不允许在子进程中再次创建进程。 | 191e41f4b71Sopenharmony_ci| NCP_ERR_MAX_CHILD_PROCESSES_REACHED | 到达最大Native子进程数量限制,不能再创建子进程。 | 192e41f4b71Sopenharmony_ci| NCP_ERR_LIB_LOADING_FAILED | 子进程加载动态库失败,文件不存在或者未实现对应的方法并导出。 | 193e41f4b71Sopenharmony_ci| NCP_ERR_CONNECTION_FAILED | 子进程调用动态库的OnConnect方法失败,可能返回了无效的IPC对象指针。 | 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci### NativeChildProcess_IsolationMode 196e41f4b71Sopenharmony_ci 197e41f4b71Sopenharmony_ci``` 198e41f4b71Sopenharmony_cienum NativeChildProcess_IsolationMode 199e41f4b71Sopenharmony_ci``` 200e41f4b71Sopenharmony_ci 201e41f4b71Sopenharmony_ci**描述** 202e41f4b71Sopenharmony_ci 203e41f4b71Sopenharmony_ci定义Native子进程独立模式。 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci**起始版本:** 13 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 208e41f4b71Sopenharmony_ci| ----------------------------------- | ----------------------------------------------- | 209e41f4b71Sopenharmony_ci| NCP_ISOLATION_MODE_NORMAL | 普通进程独立模式,与主进程共享数据沙箱和网络环境。| 210e41f4b71Sopenharmony_ci| NCP_ISOLATION_MODE_ISOLATED | 独立沙箱进程模式,与主进程不共享数据沙箱和网络环境。 | 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci## 函数说明 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ci### OH_Ability_CreateNativeChildProcess 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci``` 217e41f4b71Sopenharmony_ciint OH_Ability_CreateNativeChildProcess (const char *libName, OH_Ability_OnNativeChildProcessStarted onProcessStarted ) 218e41f4b71Sopenharmony_ci``` 219e41f4b71Sopenharmony_ci 220e41f4b71Sopenharmony_ci**描述**: 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ci创建子进程并加载参数中指定的动态链接库文件,进程启动结果通过回调参数异步通知,需注意回调通知为独立线程,回调函数实现需要注意线程同步,且不能执行高耗时操作避免长时间阻塞。 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci参数所指定的动态库必须实现并导出下列函数: 225e41f4b71Sopenharmony_ci 226e41f4b71Sopenharmony_ci 1. OHIPCRemoteStub* NativeChildProcess_OnConnect() 227e41f4b71Sopenharmony_ci 2. void NativeChildProcess_MainProc() 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci处理逻辑顺序如下列伪代码所示: 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci 主进程: 232e41f4b71Sopenharmony_ci 1. OH_Ability_CreateNativeChildProcess(libName, onProcessStartedCallback) 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci 子进程 : 235e41f4b71Sopenharmony_ci 2. dlopen(libName) 236e41f4b71Sopenharmony_ci 3. dlsym("NativeChildProcess_OnConnect") 237e41f4b71Sopenharmony_ci 4. dlsym("NativeChildProcess_MainProc") 238e41f4b71Sopenharmony_ci 5. ipcRemote = NativeChildProcess_OnConnect() 239e41f4b71Sopenharmony_ci 6. NativeChildProcess_MainProc() 240e41f4b71Sopenharmony_ci 241e41f4b71Sopenharmony_ci 主进程 : 242e41f4b71Sopenharmony_ci 7. onProcessStartedCallback(ipcRemote, errCode) 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci 子进程 : 245e41f4b71Sopenharmony_ci 8. 在NativeChildProcess_MainProc()函数返回后子进程退出。 246e41f4b71Sopenharmony_ci 247e41f4b71Sopenharmony_ci> **说明:** 248e41f4b71Sopenharmony_ci> 249e41f4b71Sopenharmony_ci> 当前仅支持2in1设备,且单个进程只能启动一个Native子进程。 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci**起始版本:** 12 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ci**参数**: 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci| 名称 | 描述 | 256e41f4b71Sopenharmony_ci| ------------------------ | --------------------------------------------------------------------------------------------------------------- | 257e41f4b71Sopenharmony_ci| libName | 子进程中加载的动态库文件名称,不能为nullptr。 | 258e41f4b71Sopenharmony_ci| onProcessStartedCallback | 通知子进程启动结果的回调函数指针,不能为nullptr,详见[OH_Ability_OnNativeChildProcessStarted](#oh_ability_onnativechildprocessstarted) | 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci**返回**: 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci执行成功返回NCP_NO_ERROR,失败返回错误码,详见[Ability_NativeChildProcess_ErrCode](#ability_nativechildprocess_errcode)。 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci### OH_Ability_StartNativeChildProcess 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ci``` 268e41f4b71Sopenharmony_ciAbility_NativeChildProcess_ErrCode OH_Ability_StartNativeChildProcess( 269e41f4b71Sopenharmony_ci const char* entry, NativeChildProcess_Args args, 270e41f4b71Sopenharmony_ci NativeChildProcess_Options options, int32_t *pid) 271e41f4b71Sopenharmony_ci``` 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci**描述**: 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci启动Native子进程,加载参数中指定的动态链接库文件并调用入口函数。支持传参到子进程。子进程中不支持创建ArkTS基础运行时环境。 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci参数所指定的动态库必须实现参数为[NativeChildProcess_Args](#nativechildprocess_args)入口函数并导出。详见[Native子进程开发指导(C/C++)- 创建支持参数传递的子进程](../../application-models/capi_nativechildprocess_development_guideline.md#创建支持参数传递的子进程)。 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ci> **说明:** 280e41f4b71Sopenharmony_ci> 281e41f4b71Sopenharmony_ci> 当前仅支持2in1、tablet设备。 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_ci**起始版本:** 13 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci**参数**: 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci| 名称 | 描述 | 288e41f4b71Sopenharmony_ci| ---------------------- | ---------------- | 289e41f4b71Sopenharmony_ci| entry | 子进程中调用动态库的符号和入口函数,中间用“:”隔开(例如“libentry.so:Main”)。不能为nullptr。 | 290e41f4b71Sopenharmony_ci| args | 传给子进程的参数,详见[NativeChildProcess_Args](#nativechildprocess_args)定义。 | 291e41f4b71Sopenharmony_ci| options | 子进程的启动配置选项,详见[NativeChildProcess_Options](#nativechildprocess_options)定义。 | 292e41f4b71Sopenharmony_ci| pid | 启动子进程号。 | 293e41f4b71Sopenharmony_ci 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ci**返回**: 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci执行成功返回NCP_NO_ERROR,失败返回错误码,详见[Ability_NativeChildProcess_ErrCode](#ability_nativechildprocess_errcode)。