Given a filename in C, I want to determine whether this file exists and has execute permission on it. All I’ve got currently is:
if( access( filename, X_OK) != 0 ) {
But this wont search the PATH for files and will also match directories (which I don’t want). Could anyone please help?
Edit:
As an alternative, seeing as I’m running execvp() in a child process, is there a way to check the return value of execvp() and signal the parent process to die with an error message?
Ended up having to set the FD_CLOEXEC flag on a new pipe and writing an error message through it after the exec if it had failed. I could then read the error message from the parent and determine whether exec was successful or not.
Thanks for your effort though guys, upvoted for the help