execl

Executes the program pointed to by the path parameter.

Library:LibC
Classification:POSIX
Service:General C Services

Syntax

  #include <unistd.h>
  
  int execl (
     const char  *path,
     const char  *arg0,
     ...
  );
  

Parameters

path

Points to the path of a file to execute.

arg0

Points to the file name that is associated with the file to execute.

...

Points to one or more null-terminated strings (which can be represented by arg1, arg2, . . . argn) that represent the parameter list that is available to the executed program. The list of parameters must be terminated by a NULL pointer.

Return Values

If an error occurs, returns -1 and errno is set to indicate the error. Otherwise, nothing is returned.

Decimal

Constant

Description

1

ENOENT

The file, script, or ELF interpreter does not exist or a shared library needed for the file or interpreter cannot be found.

2

E2BIG

The parameter list is too big.

3

ENOEXEC

The executable is not in a recognized format, is for the wrong architecture, or has some other format error that means it cannot be executed.

5

ENOMEM

Not enough kernel memory exists.

6

EACCES

The file or script interpreter is not a regular file; you don't have execute permission for the file, script, or ELF interpreter; the file system is mounted as noexec; or you don't have search permission for the file or script interpreter.

9

EINVAL

An ELF executable has more than one PT_INTERP segments (because it tried to name more than one interpreter).

10

ENFILE

The limit on the total number of files open on the system was reached.

11

EMFILE

The process has the maximum number of files open.

27

EFAULT

The file points outside your accessible address space.

28

EIO

An I/O error occurred.

64

EISDIR

An ELF interpreter was a directory.

65

ENAMETOOLONG

The file name is too long.

67

ENOTDIR

A component of the path prefix of the file, script, or ELF interpreter is not a directory.

69

EPERM

The file system is mounted as nosuid, the user is not the superuser, and the file has an SUID or SGID bit set. The process is being traced, the user is not the superuser, and the file has an SUID or SGID bit set.

85

ELOOP

There are too many symbolic links in the file, script, or ELF interpreter.

Remarks

IMPORTANT:This function is only available to NLMs that link with the POSIX semantics flag and load into protected address space (ring3). If these requirements are not met, errno is set to ENOSYS.

The execl function uses the environ external variable as the environment for the new process.

The number of bytes available for the new process's combined parameter and environment lists is defined by ARG_MAX.

See Also