#include <iostream>
#include <unistd.h>
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>

int main() {
        pid_t pid=fork();
        if (pid>0) {
                //parent
                std::cout << "Started parend zombie factory PID="
                << pid;
                
        } else {
        setsid();
        std::cout << "Factory in the background \n";
        std::cout << "Background PID=" << getpid() <<"\n";
        for (int i=0;i<5;i++) {
                 pid_t child=fork();
                 if (child==0) {
                         _exit(0);
                 }
                 sleep(1);
        }
        std::cout << "Created 5 zombies";
        }
        
        while (true) {
                sleep(60);
        }
        return 0;
}
