_spawnl、_wspawnl_spawnl, _wspawnl

创建并执行更新过程。Creates and executes a new process.


此 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 _spawnl(
   int mode,
   const char *cmdname,
   const char *arg0,
   const char *arg1,
   ... const char *argn,
intptr_t _wspawnl(
   int mode,
   const wchar_t *cmdname,
   const wchar_t *arg0,
   const wchar_t *arg1,
   ... const wchar_t *argn,


调用进程的执行模式。Execution mode for the calling process.

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

arg0arg1,...argnarg0, arg1, ... argn
指向参数的指针的列表。List of pointers to arguments. Arg0自变量通常是一个指向cmdnameThe arg0 argument is usually a pointer to cmdname. 自变量arg1通过argn是指向构成新参数列表的字符字符串的指针。The arguments arg1 through argn are pointers to the character strings forming the new argument list. 以下argn,必须有NULL指针,用以标记自变量列表的末尾。Following argn, there must be a NULL pointer to mark the end of the argument list.

返回值Return Value

返回值从同步 _spawnl_wspawnl (_P_WAIT指定的模式) 是新进程的退出状态。The return value from a synchronous _spawnl or _wspawnl (_P_WAIT specified for mode) is the exit status of the new process. 返回值从异步 _spawnl_wspawnl (_P_NOWAIT_P_NOWAITO指定的模式) 是进程句柄。The return value from an asynchronous _spawnl or _wspawnl (_P_NOWAIT or _P_NOWAITO specified for mode) is the process handle. 如果进程正常终止,则退出状态为 0。The exit status is 0 if the process terminated normally. 则可以将退出状态设置为非零值,如果生成的进程专门调用退出例程具有非零参数。You can set the exit status to a nonzero value if the spawned process specifically calls the exit routine with a nonzero argument. 如果更新过程没有显式设置正退出状态,则正退出状态指示因中止或中断而异常退出。If the new process did not explicitly set a positive exit status, a positive exit status indicates an abnormal exit with an abort or an interrupt. 返回值-1 指示的错误 (不启动新过程)。A return value of -1 indicates an error (the new process is not started). 在这种情况下, errno设置为以下值之一。In this case, errno is set to one of the following values.

E2BIGE2BIG 参数列表超过 1024 个字节。Argument list exceeds 1024 bytes.
EINVALEINVAL 模式参数无效。mode argument is invalid.
ENOENTENOENT 未找到文件或路径。File or path is not found.
ENOEXECENOEXEC 指定的文件不是可执行文件或者有无效的可执行文件格式。Specified file is not executable or has invalid executable-file format.
ENOMEMENOMEM 没有足够的内存可用于执行新进程。Not enough memory is available to execute the new process.

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

这些函数验证其参数。These functions validate their parameters. 如果任一cmdnamearg0为空字符串或 null 指针,无效参数处理程序调用中所述,参数验证If either cmdname or arg0 is an empty string or a null pointer, the invalid parameter handler is invoked, 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 spawned.


这些函数将创建并执行一个新进程,并将每个命令行实参作为独立的形参传递。Each of these functions creates and executes a new process, passing each command-line argument as a separate parameter.


例程Routine 必需的标头Required header
_spawnl_spawnl <process.h><process.h>
_wspawnl_wspawnl <stdio.h> 或 <wchar.h><stdio.h> or <wchar.h>

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


在参见 _spawn、_wspawn 函数中的示例。See the example in _spawn, _wspawn Functions.

请参阅See also

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