Редактиране

Споделяне чрез


_execvpe, _wexecvpe

Loads and runs new child processes.

Important

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.

Syntax

intptr_t _execvpe(
   const char *cmdname,
   const char *const *argv,
   const char *const *envp
);
intptr_t _wexecvpe(
   const wchar_t *cmdname,
   const wchar_t *const *argv,
   const wchar_t *const *envp
);

Parameters

cmdname
Path of the file to execute.

argv
Array of pointers to parameters.

envp
Array of pointers to environment settings.

Return value

If successful, these functions don't return to the calling process. A return value of -1 indicates an error, in which case the errno global variable is set.

errno value Description
E2BIG The space that's required for the arguments and environment settings exceeds 32 KB.
EACCES The specified file has a locking or sharing violation.
EMFILE Too many files are open. (The specified file must be opened to determine whether it's executable.)
ENOENT The file or path isn't found.
ENOEXEC The specified file isn't executable or has an invalid executable-file format.
ENOMEM Not enough memory is available to execute the new process; the available memory has been corrupted; or an invalid block exists, which indicates that the calling process wasn't allocated correctly.

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

Remarks

Each of these functions loads and executes a new process, and passes an array of pointers to command-line arguments and an array of pointers to environment settings. These functions use the PATH environment variable to find the file to execute.

The _execvpe functions validate their parameters. These functions invoke the invalid parameter handler, as described in Parameter validation, when:

  • cmdname is a null pointer,
  • argv is either a null pointer or pointer to an empty array,
  • the array contains an empty string as the first argument.

If execution is allowed to continue by the handler, these functions set errno to EINVAL, and return -1. No process is launched.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

Function Required header Optional header
_execvpe <process.h> <errno.h>
_wexecvpe <process.h> or <wchar.h> <errno.h>

For more compatibility information, see Compatibility.

Example

See the example in _exec, _wexec functions.

See also

Process and environment control
_exec, _wexec functions
abort
atexit
exit, _Exit, _exit
_onexit, _onexit_m
_spawn, _wspawn functions
system, _wsystem