Помогите исправить
Код: Выделить всё
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
void main(void)
{ int pid2, pid3, st;
printf("Process 1, pid = %d:\n", getpid());
pid2 = fork();
if (pid2 == 0)
{ printf("Process 2, pid = %d:\n", getpid());
pid3 = fork();
if (pid3 == 0)
{ printf("Process 3, pid = %d:\n", getpid());
sleep(2);
printf("Process 3: end\n");
}
if (pid3 < 0) printf("Cann't create process 3: error %d\n", pid3);
wait(&st);
printf("Process 2: end\n");
}
else
{ if (pid2 < 0) printf("Cann't create process 2: error %d\n", pid2);
wait(&st);
printf("Process 1: end\n");
}
exit(0);
}