0

I already read the man page and did some googling. Couldn't find anything. Say I run execl with a path argument that doesn't actually contain the program specified in arg[0].

What will it do?

temporary_user_name
  • 35,956
  • 47
  • 141
  • 220
  • 2
    What's so bad about trying it? What's the worst that could possibly happen? – nneonneo Sep 30 '12 at 04:19
  • Agree - worst possible case would be an OS reinstall ;-) – Adrian Cornish Sep 30 '12 at 04:21
  • The man page says "The `execl()`, `execle()`, `execlp()`, `execvp()`, and `execvP()` functions may fail and set `errno` for any of the errors specified for the library functions `execve(2)` and `malloc(3)`." Did you look at those man pages? – Carl Norum Sep 30 '12 at 04:22

1 Answers1

2

It returns -1 and sets errno (just try it!). It sets errno depending on the exact problem encountered.

From the man page:

Errors

EACCES Search permission is denied on a component of the path prefix of filename or the name of a script interpreter. (See also path_resolution(7).)

ENAMETOOLONG filename is too long.

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

ENOTDIR A component of the path prefix of filename or a script or ELF interpreter is not a directory.

nneonneo
  • 171,345
  • 36
  • 312
  • 383