_execlp,_wexeclp_execlp, _wexeclp

加载和执行新的子进程。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.

语法Syntax

intptr_t _execlp(
   const char *cmdname,
   const char *arg0,
   ... const char *argn,
   NULL
);
intptr_t _wexeclp(
   const wchar_t *cmdname,
   const wchar_t *arg0,
   ... const wchar_t *argn,
   NULL
);

参数Parameters

cmdnamecmdname
要执行的文件的路径。Path of the file to execute.

arg0,...argnarg0, ... argn
指向参数的指针的列表。List of pointers to 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.

errnoerrno 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.
EMFILEEMFILE 打开的文件太多 (必须打开指定的文件以确定它是否是可执行文件)。Too many files open (the specified file must be opened to determine whether it is executable).
ENOENTENOENT 未找到文件或路径。The file or path 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.

有关这些属性和其他的更多信息返回代码示例,请参见 _doserrno、errno、_sys_errlist 和 _sys_nerrFor more information about these and other return codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.

备注Remarks

其中每个函数加载并执行一个新进程,将每个命令行自变量作为单独的参数传递和使用路径环境变量查找要执行的文件。Each of these functions loads and executes a new process, passing each command-line argument as a separate parameter and using the PATH environment variable to find the file to execute.

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

要求Requirements

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

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

示例Example

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

请参阅See also

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