_execl,_wexecl_execl, _wexecl

加载和执行新的子进程。Loads and executes new child processes.


此 API 不能用于在 Windows 运行时中执行的应用程序。This API cannot be used in applications that execute in the Windows Runtime. 有关详细信息,请参阅通用 Windows 平台应用中不支持的 CRT 函数For more information, see CRT functions not supported in Universal Windows Platform apps.


intptr_t _execl(
   const char *cmdname,
   const char *arg0,
   ... const char *argn,
intptr_t _wexecl(
   const wchar_t *cmdname,
   const wchar_t *arg0,
   ... const wchar_t *argn,


要执行的文件的路径。Path of the file to be executed.

arg0,...argnarg0, ... argn
指向参数的指针的列表。List of pointers to the parameters.

返回值Return Value

如果成功,这些函数不返回到调用进程。If successful, these functions do not return to the calling process. 返回值-1 指示错误,在这种情况下errno设置全局变量。A return value of -1 indicates an error, in which case the errno global variable is set.

errno 值errno value 描述Description
E2BIGE2BIG 自变量和环境设置所需的空间超过 32 KB。The space required for the arguments and environment settings exceeds 32 KB.
EACCESEACCES 指定的文件具有锁定或共享冲突。The specified file has a locking or sharing violation.
EINVALEINVAL 无效参数(一个或多个参数为空指针或空字符串)。Invalid parameter (one or more of the parameters was a null pointer or empty string).
EMFILEEMFILE 打开的文件太多 (必须打开指定的文件以确定它是否是可执行文件)。Too many files open (the specified file must be opened to determine whether it is executable).
ENOENTENOENT 未找到文件或路径。The file or path is not found.
ENOEXECENOEXEC 指定的文件不是可执行文件或者有无效的可执行文件格式。The specified file is not executable or has an invalid executable-file format.
ENOMEMENOMEM 没有足够的内存可用于执行更新进程;可用内存损坏;或存在无效的块,指示调用进程未正确分配。Not enough memory is available to execute the new process; the available memory has been corrupted; or an invalid block exists, indicating that the calling process was not allocated properly.


这些函数将加载并执行一个新进程,并将每个命令行实参作为独立的形参传递。Each of these functions loads and executes a new process, passing each command-line argument as a separate parameter. 第一个参数是命令或执行文件名称,而第二个参数应与第一个相同。The first argument is the command or executable file name, and the second argument should be the same as the first. 它将成为执行过程中的 argv[0]It becomes argv[0] in the executed process. 第三个参数是要执行过程的第一个参数 argv[1]The third argument is the first argument, argv[1], of the process being executed.

_Execl函数验证其参数。The _execl functions validate their parameters. 如果任一cmdnamearg0是 null 指针或空字符串,这些函数将调用无效参数处理程序中所述参数验证如果执行若要继续,这些函数将设置为允许errnoEINVAL并返回-1。If either cmdname or arg0 is a null pointer or empty string, these functions invoke the invalid parameter handler as described in Parameter Validation If execution is allowed to continue, these functions set errno to EINVAL and return -1. 不执行任何新进程。No new process is executed.


函数Function 必需的标头Required header 可选标头Optional header
_execl_execl <process.h><process.h> <errno.h><errno.h>
_wexecl_wexecl <process.h> 或 <wchar.h><process.h> or <wchar.h> <errno.h><errno.h>

有关更多兼容性信息,请参阅 兼容性For more compatibility information, see Compatibility.


请参阅 _exec、_wexec 函数中的示例。See the example in _exec, _wexec Functions.

请参阅See also

进程和环境控制Process and Environment Control
_exec、_wexec 函数_exec, _wexec Functions
exit、_Exit、_exitexit, _Exit, _exit
_onexit、_onexit_m_onexit, _onexit_m
_spawn、_wspawn 函数_spawn, _wspawn Functions
system、_wsystemsystem, _wsystem