我有一个小型 C 程序,调用 shell 脚本 myScript.sh。我得到的 ret 值为 256。请帮助我了解系统调用出了什么问题?
int main()
{
int ret;
ret = system (myScript.sh);
ret >>= ret;
if (ret != 0)
{
printf("ret is [%d]",ret);
}
}
在 64 位 UNIX 操作系统上工作并使用 ksh shell
在我的系统上,man system
says:
The system() function returns the exit status of the shell as returned by
waitpid(2), or -1 if an error occurred when invoking fork(2) or
waitpid(2). A return value of 127 means the execution of the shell
failed.
The waitpid
手册页描述了一组宏,例如WEXITSTATUS()
从返回值中提取实际的退出代码。
我不太确定你打算做什么ret >>= ret
,但这不可能是正确的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)