Fijate si te anda esto... después nos contás.
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
void get_possible_error(int value, const char *);
void wait_process(pid_t, const char *);
int main() {
pid_t child1_id=-1, child2_id=-1, child3_id=-1;
child1_id = fork();
get_possible_error(child1_id, "fork() child1_id");
if(child1_id == 0) { /* hijo1 */
/* sentencias... */
} else { /* child1_id > 0 => padre */
child2_id = fork();
get_possible_error(child2_id, "fork() child2_id");
if(child2_id == 0) { /* hijo2 */
/* sentencias... */
} else { /* padre */
child3_id = fork();
get_possible_error(child3_id, "fork() child3_id");
if(child3_id == 0) { /* hijo 3 */
/* sentencias... */
}
else { /* padre */
wait_process(child1_id, "wait() child1");
wait_process(child2_id, "wait() child2");
wait_process(child3_id, "wait() child3");
}
}
}
return 0;
}
void get_possible_error(int value, const char *str) {
if(value<0) {
}
}
void wait_process(pid_t pid, const char *str) {
pid = wait(&pid);
get_possible_error(pid, str);
}