Skip to content

Latest commit

 

History

History
106 lines (85 loc) · 4.94 KB

spawnve-wspawnve.md

File metadata and controls

106 lines (85 loc) · 4.94 KB
title ms.custom ms.date ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic apiname apilocation apitype f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
_spawnve, _wspawnve | Microsoft Docs
11/04/2016
cpp-standard-libraries
article
_spawnve
_wspawnve
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-process-l1-1-0.dll
DLLExport
wspawnve
_spawnve
_wspawnve
spawnve
C++
_spawnve function
spawnve function
wspawnve function
processes, creating
_wspawnve function
processes, executing new
process creation
26d1713d-b551-4f21-a07b-e9891a2ae6cf
17
corob-msft
corob
ghogen

_spawnve, _wspawnve

Creates and executes a new process.

Important

This API cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported with /ZW.

Syntax

intptr_t _spawnve(  
   int mode,  
   const char *cmdname,  
   const char *const *argv,  
   const char *const *envp   
);  
intptr_t _wspawnve(  
   int mode,  
   const wchar_t *cmdname,  
   const wchar_t *const *argv,  
   const wchar_t *const *envp   
);  

Parameters

mode
Execution mode for a calling process.

cmdname
Path of the file to be executed.

argv
Array of pointers to arguments. The argument argv[0] is usually a pointer to a path in real mode or to the program name in protected mode, and argv[1] through argv[n] are pointers to the character strings forming the new argument list. The argument argv[n +1] must be a NULL pointer to mark the end of the argument list.

envp
Array of pointers to environment settings.

Return Value

The return value from a synchronous _spawnve or _wspawnve (_P_WAIT specified for mode) is the exit status of the new process. The return value from an asynchronous _spawnve or _wspawnve (_P_NOWAIT or _P_NOWAITO specified for mode) is the process handle. 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. A return value of -1 indicates an error (the new process is not started). In this case, errno is set to one of the following values.

E2BIG
Argument list exceeds 1024 bytes.

EINVAL
mode argument is invalid.

ENOENT
File or path is not found.

ENOEXEC
Specified file is not executable or has invalid executable-file format.

ENOMEM
Not enough memory is available to execute the new process.

For more information about these and other return codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.

Remarks

Each of these functions creates and executes a new process, passing an array of pointers to command-line arguments and an array of pointers to environment settings.

These functions validate their parameters. If either cmdname or argv is a null pointer, or if argv points to null pointer, or argv[0] is an empty string, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, these functions set errno to EINVAL, and return -1. No new process is spawned.

Requirements

Routine Required header
_spawnve <stdio.h> or <process.h>
_wspawnve <stdio.h> or <wchar.h>

For more compatibility information, see Compatibility.

Example

See the example in _spawn, _wspawn Functions.

See Also

Process and Environment Control
_spawn, _wspawn Functions
abort
atexit
_exec, _wexec Functions
exit, _Exit, _exit
_flushall
_getmbcp
_onexit, _onexit_m
_setmbcp
system, _wsystem