Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #define COUNT 4
- int main(void) {
- int count = COUNT, children = 0;
- pid_t retpid = 1;
- while (count-- > 0 && retpid > 0)
- if ((retpid = fork()) > 0)
- children++;
- if (retpid != 0) {
- printf("Parent PID %d\n", getpid());
- while (children-- > 0)
- wait(NULL);
- } else {
- printf("Child PID %d, PPID %d\n", getpid(), getppid());
- }
- sleep(90);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement