I have my code running on the Mac and I am getting a 255 return code from exec. The following is the code:
ret = execvp(pArgs[0], pArgs);
if (ret < 0)
{
ret = errno;
exit(ret);
return false;
}
else if (processId < 0)
{
// fork() failed
return false;
}
else if(Wait)
{
// forked successfuly so wait for exit
if(waitpid(processId, &childstatus, 0) == processId)
{
// codesign command terminted, get return code
if(WIFEXITED(childstatus))
{
if(pCmdRetStatus != NULL)
*pCmdRetStatus = WEXITSTATUS(childstatus);
}
}
}
Any thoughts on why the 255? Essentially an hdiutil call, a lot of times, I get 255.
UNIX (and therefore Mac OS X) exit statuses are forced into the range 0-255 unsigned.
So a return value of -1 from your call to execvp would be processed as -1 in your C code but would become 255 at the operating-system level due to the rules of the exit() function specification. Consider the following example:
bash> bash
bash2> exit -1
bash> echo $? # The exit status of the last command (bash2)
255
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With