The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

Please Log In to Continue

It fails and returns false only if the command does not
exist *and* it is executed directly instead of via your system's
command shell (see below).

Under what conditions do you expect the call to fail? Unless the docs are wrong, if the program you are trying to execute exists, you will never get a false value from exec. Perhaps system() would be a better choice, and you can handle terminating the child process manually?

Non-zero exit code from the child. Your wait call's return value can be used to make sure that you get the expected child's death. You can use a time-out, since "success" probably means that the child never effectively exits (or if it does, the time-out is probably not needed). When wait returns the PID of the deceased child, $? will have the status/exit code.

Maybe you can use some variant of the following? We use Windows boxes at work (damn it!), so I rarely get a chance to do much nifty stuff with forking. As a result, I could totally be smoking crack with this.