Can exec() return true on success or false on failure?

I am using exec() to send print jobs with Ghostscript. I need to keep track of any exec() failures to alert the user.

The way I read the documentation exec() doesn’t simply return true or false Even with all 3 arguments. Am I reading it wrong? Is there a way to make it return true on success and false on failure?

Thanks in advance.

Maybe you not using it correctly then.
try this:

exec($command, $out, $ret);
echo 'return: '.$ret;

If you need return value of command then you should use it differently.

something like this:
exec($command, $out);
then examine the $out which should be an array of lines that you would normally get if executing command from command line.

Then examine this array and determine if it was a success or not. this really depends on what your command usually prints out on success. Many command don’t print anyting on success, in which case you should expect $out to be empty in case of success, otherwise will contain error message.

There is also a third argument $returnVar. It usually contains the return code as reported by program. You can examine it also.