Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

_spawnv, _wspawnv

Create and execute a new process.

intptr_t _spawnv(
   int mode,
   const char *cmdname,
   const char *const *argv 
);
intptr_t _wspawnv(
   int mode,
   const wchar_t *cmdname,
   const wchar_t *const *argv 
);

Parameters

mode
Execution mode for calling process
cmdname
Path of file to be executed
argv
Array of pointers to arguments

Return Value

The return value from a synchronous _spawnv or _wspawnv (_P_WAIT specified for mode) is the exit status of the new process. The return value from an asynchronous _spawnv or _wspawnv (_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 new process

See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, return codes.

Remarks

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

Requirements

Routine Required header Compatibility
_spawnv <stdio.h> or <process.h> Win 98, Win Me, Win NT, Win 2000, Win XP
_wspawnv <stdio.h> or <wchar.h> Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

Example

See the example in _spawn, _wspawn Functions.

See Also

Process and Environment Control Routines | _spawn Functions Overview | abort | atexit | _exec Functions | exit | _flushall | _getmbcp | _onexit | _setmbcp | system | Run-Time Routines and .NET Framework Equivalents

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.