#include <iostream>
#include <unistd.h>
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
using namespace std;
int main () {
pid_t pid=fork();
if (pid>0) {
cout<< " started parent zombie factory PID="
<<pid ;
} else {
setsid();
cout<<"factory in the background \n";
cout<<"background PID="<< getpid() <<"\n";
for (int i=0; i<5; i++) {
pid_t child=fork();
if (child==0) {
   _exit(0);
   }
   sleep(1);
   }
   cout<<"created 5 zombies";
   }
   while (true) {
   sleep(60);
   }
   return 0;
   }
