我有我的代码在Mac上运行,我得到一个来自exec的255返回码。 以下是代码:exec返回255
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);
}
}
}
对于为什么255的任何想法?本质上是一个hodiutil调用,很多次,我得到了255.
如果你把'printf(“%s \ n”, strerror(errno));在调用execvp后(如果返回,它总是返回-1),如果成功则不返回)。 –
'perror()'说什么? 'execve'手册页有很多可能会失败的原因。 –
['execvp'](http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html)!= ['fork'](http://pubs.opengroup.org/onlinepubs/9699919799/functions /fork.html) – pmg