File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ package nuv_utils;
44 our @ISA = qw/ Exporter / ;
55 our @EXPORT = qw/ generate_showtime find_program nuv_info num_cpus fork_command shell_escape mysql_escape Quit / ;
66
7+ # This is used to tell child processes apart from the parent, so that cleanup routines do NOT get run by children.
8+ our $is_child = 0;
9+
710# Returns a nicely-formatted timestamp from a specified time
811 sub generate_showtime {
912 $showtime = ' ' ;
@@ -194,6 +197,7 @@ package nuv_utils;
194197 }
195198 # $pid defined means that this is now the forked child
196199 elsif (defined $pid ) {
200+ $is_child = 1;
197201 system ($command );
198202 # Don't forget to exit, or we'll keep going back into places that the child shouldn't play
199203 exit (0);
@@ -221,9 +225,9 @@ package nuv_utils;
221225 exit ;
222226 }
223227
224- # Allow the functions to clean up after themselves - and make sure that they can
228+ # Allow the functions to clean up after themselves - and make sure that they can, but not if they are marked as child processes
225229 END {
226- if (@main::Functions ) {
230+ if (! $is_child && @main::Functions ) {
227231 foreach $function (@main::Functions ) {
228232 $function -> cleanup;
229233 }
You can’t perform that action at this time.
0 commit comments