cbolcato has asked for the wisdom of the Perl Monks concerning the following question:

I have a script "SCRIPT1" use a system() function call to another perl script "SCRIPT2" that uses DBI. It appears that SCRIPT1 finishes prior to SCRIPT2. HOW COULD THIS BE???\n

I haven't been able to re-create the failure with test code, and I cannot post production code, but $? >> 8 = 16777215 for SCRIPT1 while SCRIPT2 is still running.

The following line of code were executed immediately after the system() and produced the out put below:

Oh, did I mention that it does not fail everytime!!

The following code was added and return the results stated below:

if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; } $exit_value = $? >> 8; $signal_num = $? & 127; $dumped_core = $? & 128; print "$?\n"; print "$exit_value\n"; print "$signal_num\n"; print "$dumped_core\n"; print "$!\n";

failed to execute: Illegal seek
child exited with value 127

Problem Solved

The suggestion made by bluto that SCRIPT1 may be getting signaled got me thinking and testing along that path.

What I found is that SCRIPT2 wasn't sending a signal, but SCRIPT1 had an alarm set that would trigger the updating of a timestamp in a logfile.

If that alarm tripped while SCRIPT1 was waiting for a return from the system() call, control would come back to SCRIPT1 prior to SCRIPT2 completing, thus causing our failure condition.

Once, I identified the problem I have been able to re-create this senario in test.

The resolution was to turn the alarm off "alarm(0);" prior to performing the system() call.

Thanks, to all who responded. cbolcato