Go to main content

man pages section 2: System Calls

Exit Print View

Updated: Thursday, June 13, 2019
 
 

execvex(2)

Name

execvex - execute a file

Synopsis

#include <sys/execx.h>

int execvex(uintptr_t file, char *const argv[], char *const envp[],
    int flags);

Description

All of the interfaces described in exec() are implemented using calls to the fundamental execvex() system call described here. See exec(2) for details of process execution and return values from the system call.

The interpretation of the file argument depends on the value of the flags argument. The value of the flags argument must be an inclusive-OR of zero or more of these values:

  • EXEC_DESCRIPTOR
  • EXEC_RETAINNAME
  • EXEC_ARGVNAME

If EXEC_DESCRIPTOR is set in flags, the file argument must be an open file descriptor for a regular file that is executable by the calling process. The file may have been opened with any of these access modes (see open(2)):

  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_EXEC

If EXEC_DESCRIPTOR is not set in flags, the file argument must be a pointer to a pathname for a file that is executable by the calling process.

If EXEC_RETAINNAME is set in flags, the process's name, contained in the kernel user structure u_comm[] member, fetched in the /proc/pid/psinfo pr_fname [] member, reported by ps(1) and interrogated by pgrep(1), remains unchanged across the exec() of the new image.

If EXEC_DESCRIPTOR or EXEC_ARGVNAME is set in flags and EXEC_RETAINNAME is not set, the process's name becomes the last component of the pathname-like argv[0] argument.

If none of the EXEC_DESCRIPTOR, EXEC_RETAINNAME or EXEC_ARGVNAME flags are set in flags, the name of the process becomes the last component of the pathname passed in the file argument.

A call to execvex() with no flags:

execvex((uintptr_t)pathname, argv, envp, 0);

is equivalent to a call to execve():

execve(pathname, argv, envp);

A call to execvex() with only the EXEC_DESCRIPTOR flag:

execvex(fd, argv, envp, EXEC_DESCRIPTOR);

is equivalent to a call to fexecve():

fexecve(fd, argv, envp);

Return Values

If the execvex() function returns to the calling process image, an error has occurred; the return value is -1 and errno is set to indicate the error.

Errors

In addition to the failures described in exec(2), the execvex() function will fail if:

EINVAL

The flags argument is invalid.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
Async-Signal-Safe

See Also

pgrep(1), ps(1), exec(2), open(2), proc(5), attributes(7)