1
我想调用一个程序并获得它的返回值。我用fork()
和execv()
来调用子进程,现在正在等待状态,但我收到56
作为退出状态,我不明白为什么。我已经单独检查了子进程,它工作得很好。退出状态56时调用子进程
56是什么意思,我该如何解决?
这是一部分相关代码:
pid_t pid = fork();
if (pid < 0)
// handle error
if (pid == 0)
execv(filename, argv); // calls child process
waitpid(pid, &status, 0);
if (WIFEXITED(status))
// handle success
else if(WIFSIGNALED(status))
printf("%d\n", (int) WTERMSIG(status)); // here I get 56 now, when I print the error using stderror I get this: "Invalid request code"
请显示一些相关的代码。 –
这非常含糊,程序输出不同的退出代码。尝试在您的子进程中执行您正在执行的程序,看看它是否有退出代码列表。 – photoionized
你有没有考虑过使用errno? – squiguy