0

I am executing a binary with execl. This is all working OK, waitpid returns a correct pid, WIFEXITED(pidstatus) gives a 1 and WEXITSTATUS(pidstatus) a 0.

Now I change the permissions for that binary to restrict its access.

The binary is not being executed and execl now returns, which I believe it never should (with reason -1). However, waitpid still returns a correct pid and the macros WIFEXITED(pidstatus) and WEXITSTATUS(pidstatus) have not changed. Why do they still indicate a successful operation?

Lieuwe
  • 1,734
  • 2
  • 27
  • 41
  • 1
    `execl()` failure is just a system call failure, not an abnormal exit. – llllllllll Mar 28 '18 at 10:36
  • 2
    The `waitpid` call returns with the status of the child process. If the `execl` call in the child process fails, then the status returned by `waitpid` will *still* be the one of the child process but now *you're* in control of that status. If you let the child process exit with a zero status code, then that's what the parent process will get. – Some programmer dude Mar 28 '18 at 10:36
  • @Someprogrammerdude - that makes sense. Thanks. – Lieuwe Mar 28 '18 at 10:41

0 Answers0