Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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
16777215
127
128
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


In reply to system() does not wait by cbolcato

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2022-01-21 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (57 votes). Check out past polls.

    Notices?