About wait() and waitpid()
<p>So I wrote this code on C. I created a father, that has two child processes, and one becomes zombie. After one second it exits, and the father, that was waiting for him, finishes. The other child process remains orphan, and then finishes. My question is, what happens if I change the <code>wait</code> for <code>waitpid</code>.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;sys/wait.h&gt;
#include &lt;unistd.h&gt;

int main() {
    pid_t pid;
    int status, value;

    pid = fork();

    if (pid &gt; 0) { // Father

        pid = fork();

        if (pid &gt; 0) { // Father
            wait(&amp;status);
            value = WEXITSTATUS(status);

            if (value == 2)
                printf("Child 2");
            else if (value == 3)
                printf("Child 1");

        } else if (pid == 0) { //Child 2 - Orphan
            sleep(4);
            exit(2);

        } else {
            exit(1);
        }

    } else if (pid == 0) { // Child 1 - Zombie
        sleep(1);
        exit(3);

    } else {
        printf("Error al ejecutar el fork");
        exit(1);
    }



    return 0;
}
</code></pre>