process.execve(file[, args[, env]])
file<string> 要运行的可执行文件的名称或路径。args<string[]> 字符串参数列表。任何参数都不能包含空字节(\u0000)。env<Object> 环境键值对。键或值都不能包含空字节(\u0000)。默认值:process.env。
用新进程替换当前进程。
🌐 Replaces the current process with a new process.
这是通过使用 execve POSIX 函数实现的,因此当前进程的内存或其他资源不会被保留,除了标准输入、标准输出和标准错误文件描述符之外。
🌐 This is achieved by using the execve POSIX function and therefore no memory or other
resources from the current process are preserved, except for the standard input,
standard output and standard error file descriptor.
成功时,当进程被交换时,系统会丢弃所有其他资源,而不会触发任何退出或关闭事件,也不会运行任何 JavaScript 清理处理程序(例如 process.on('exit')),并且不会调用通过嵌入器 API 注册的本地 AtExit 回调。需要运行清理逻辑的调用者应在调用 process.execve() 之前执行清理。
🌐 On success, all other resources are discarded by the system when the
processes are swapped, without triggering any exit or close events, without
running any JavaScript cleanup handler (for example process.on('exit')),
and without invoking native AtExit callbacks registered through the
embedder API. Callers that need to run cleanup logic should do so before
calling process.execve().
此函数在成功时不会返回。如果底层 execve(2) 系统调用失败,将抛出 Error,其 code 属性设置为相应的 errno 字符串(例如,当 file 不存在时为 'ENOENT'),syscall 设置为 'execve',path 设置为 file。当 execve(2) 失败时,当前进程会继续运行,状态保持不变,因此调用者可以处理错误并采取其他操作。
🌐 This function does not return on success. If the underlying execve(2)
system call fails, an Error is thrown whose code property is set to the
corresponding errno string (for example, 'ENOENT' when file does not
exist), with syscall set to 'execve' and path set to file. When
execve(2) fails the current process continues to run with its state
unchanged, so a caller may handle the error and take another action.
此函数在 Windows 和 IBM i 上不可用。
🌐 This function is not available on Windows or IBM i.