Reputation: 5339
#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
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