user567879
user567879

Reputation: 5339

Call three forks

#include<stdio.h>
main()
{
 fork();
 fork();
 fork();
}

Theory says this code will create 8 process. Looking for a simple way to find this?

ps -e

shows only 4 processes when fork() used along with sleep() command. Is there any simple way to find other than IPC

Upvotes: 1

Views: 464

Answers (1)

wormsparty
wormsparty

Reputation: 2499

#include<stdio.h>
main()
{
    printf("x\n");

    if(!fork()) printf("x\n");
    if(!fork()) printf("x\n");
    if(!fork()) printf("x\n");
}

./a.out | wc -l

Upvotes: 3

Related Questions