How to use Fork() to create only 2 child processes?
问题 I'm starting to learn some C and while studying the fork, wait functions I got to a unexpected output. At least for me. Is there any way to create only 2 child processes from the parent? Here my code: #include <sys/types.h> #include <stdio.h> #include <unistd.h> #include <sys/wait.h> int main () { /* Create the pipe */ int fd [2]; pipe(fd); pid_t pid; pid_t pidb; pid = fork (); pidb = fork (); if (pid < 0) { printf ("Fork Failed\n"); return -1; } else if (pid == 0) { //printf("I'm the child\n