我有我的代碼在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