FORK:
if ($pid = fork()) {
    
} elsif (defined($pid)) {
    setsid; 
    
    close(STDOUT);
    close(STDIN);
    close(STDERR);    
    
    open(STDOUT, '>/dev/null');
    open(STDIN, '>/dev/null');
    open(STDERR, '>>/home/virtual/logs/err.log');

    

    exit; 
} elsif($! =~ /emporar/){
    warn '[' . localtime() . "] Failed to Fork - Will try again in 10 seconds.\n";
    sleep(10);
    goto FORK;
} else {
    warn '[' . localtime() . "] Unable to fork - $!";
    exit(0);
}