title: Get return code from linux command in C program
body: <p>I am basically trying to check if a particular file exists or not. For that I am using the test command of Unix. </p>
  
  <pre><code> sprintf(execbuf, "%s if test -r %s ; then true; else exit; fi;",
           execbuf, st-&gt;file, NO_FILE);
  </code></pre>
  
  <p>It works fine, but I do not want to exit if the file is not here, rather it should return FAIL. </p>
  
  <p>I am not able to figure out how to make the program return FAIL. I was thinking of using the exit code from the above command, but still I am not able to figure out how to use that exit code outside the Linux command in the program.   </p>