title: Check if file exists, including on PATH
body: <p>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:</p>
  
  <pre><code>if( access( filename, X_OK) != 0 ) {
  </code></pre>
  
  <p>But this wont search the PATH for files and will also match directories (which I don't want). Could anyone please help?</p>
  
  <p>Edit:</p>
  
  <p>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?</p>