How to get error of execvp in the fork()?

后端 未结 1 1097
说谎
说谎 2021-01-23 07:14

I have the following code.

My question is in the code

     int main() {

            ....

         if ((uproc.pid = fork()) == -1) {
            return          


        
相关标签:
1条回答
  • 2021-01-23 07:43

    The exit status of the child is provided by the wait function, in the status variable.

    You get the exit status by using the WEXITSTATUS macro, but only if the program exited normally (i.e. called exit or returned from its main function):

    if (WIFEXITED(status))
        printf("Child exit status: %d\n", WEXITSTATUS(status));
    else
        printf("Child exited abnormally\n");
    

    Read the manual page for wait for more information.

    0 讨论(0)
提交回复
热议问题