/* main program illustrating the UNIX fork() system call.
Compile using cc -o main main.c
*/
#include <stdio.h>
int main()
{
int pid1,pid2,pid3;
pid1=fork();
if(pid1==0)
{
pid2=fork();
if(pid2==0)
{
}
else
{
if(fork()==0){
}
}
}
else{
pid3=fork();
if(pid3==0)
{
if(fork() && fork())
{
fork();
}
}
else{
}
}
return 0;
}
LyogICAgbWFpbiBwcm9ncmFtIGlsbHVzdHJhdGluZyB0aGUgVU5JWCBmb3JrKCkgc3lzdGVtIGNhbGwuIApDb21waWxlIHVzaW5nIGNjIC1vIG1haW4gbWFpbi5jCiovCiNpbmNsdWRlIDxzdGRpby5oPgppbnQgbWFpbigpCnsKICBpbnQgcGlkMSxwaWQyLHBpZDM7CiAgcHJpbnRmKCJBICIpOwogIHBpZDE9Zm9yaygpOwogIGlmKHBpZDE9PTApCiAgewogIAkgIHByaW50ZigiQiAiKTsKICAJICBwaWQyPWZvcmsoKTsKICAJICBpZihwaWQyPT0wKQogIAkgIHsKICAJICAJcHJpbnRmKCJCICIpOwogIAkgIH0KICAJICBlbHNlCiAgCSAgewogIAkgIAlpZihmb3JrKCk9PTApewogIAkgIAlwcmludGYoIkMgIik7CgogIAkgIAl9CiAgCSAgfQpwcmludGYoIkEgIik7CiAgfQplbHNlewoJcGlkMz1mb3JrKCk7CglpZihwaWQzPT0wKQoJewoJCXByaW50ZigiRCAiKTsKCQlpZihmb3JrKCkgJiYgZm9yaygpKQoJCXsKCQkJcHJpbnRmKCJCICIpOwoJCQlmb3JrKCk7CgkJCXByaW50ZigiRCAiKTsKCQl9Cgl9CgllbHNlewoJCXByaW50ZigiQSAiKTsKCX0KCQp9CiAgICByZXR1cm4gMDsKfQog