waitpid()

Reference:

  1. https://linux.die.net/man/2/waitpid

wait() and waitpid()

The wait() system call suspends execution of the calling process until one of its children terminates. The call wait(&status) is equivalent to:

waitpid(-1, &status, 0);

The waitpid() system call suspends execution of the calling process until a child specified by pid argument has changed state. By default, waitpid() waits only for terminated children, but this behavior is modifiable via the options argument, as described below.

可以透過WEXITSTATUS來取得子程序返回的狀態值, 通常都會先用WIFEXITED來判斷子程序是否正常結束, 如果正常結束才去取得子程序的狀態值

results matching ""

    No results matching ""