close($fh); close($logfile); exit; # exit child process } waitpid($pid,0); } print "Parent Process"; close($fh); # Close file handler $fh close($logfile); # Close file handler $logfile rename ($filename, $newfilename) or die "Error in renaming $!"; # Rename the temporary to avoid node exporter seeing half a file. alarm(0);