Creates and executes a new process.
This API cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported in Universal Windows Platform apps.
const char *cmdname,
const char *const *argv
const wchar_t *cmdname,
const wchar_t *const *argv
Execution mode for the calling process.
Path of the file to be executed.
Array of pointers to arguments. The argument
argv is usually a pointer to a path in real mode or to the program name in protected mode, and
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.
The return value from a synchronous
_P_WAIT specified for
mode) is the exit status of the new process. The return value from an asynchronous
_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 didn't 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 isn't started). In this case,
errno is set to one of the following values.
|Argument list exceeds 1024 bytes.
mode argument is invalid.
|File or path isn't found.
|Specified file isn't executable or has invalid executable-file format.
|Not enough memory is available to execute the new process.
For more information about these and other return codes, see
Each of these functions creates and executes a new process, passing an array of pointers to command-line arguments.
These functions validate their parameters. If either
argv is a null pointer, or if
argv points to null pointer, or
argv is an empty string, the invalid parameter handler is invoked, as described in Parameter validation. If execution is allowed to continue, these functions set
EINVAL, and return -1. No new process is spawned.
By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.
|<stdio.h> or <process.h>
|<stdio.h> or <wchar.h>
For more compatibility information, see Compatibility.
See the example in