Hi All, I was wondering if someone could lend me a solution. I have a list of commands in a text file, that my script reads in one at a time, and then I try to execute one by one. Each command will be executed as eval $cmd; and the $cmd will the subroutine in which we will send the actual command through socket. Once the command sent, we wait for the response at max period of 90sec. Here is the requirement: I need to send couple of commands from the list for which I should not wait for the response and move to further commands. To achieve this, I planned to create child process as background for that particular command. Since our project drives with perl5.6, I had no choice to use threads to do so. Hence I created using fork.This leads to perl interpreter crach by throwing an error: Attempt to free unreferenced scalar. Here is the code that I tried to create child:

foreach (@commands) { $cmd = $_; if($cmd =~ /CGDCONT/i){ unless (fork) { eval $cmd; if ($@) { print "When executing: $cmd\nFollowing error occured: + $@\n"; } exit; } } else{ eval $cmd; if ($@) { print "When executing: $cmd\nFollowing error occured: $@\n +"; } } }
FYI.. $cmd will be holding subroutine API call from one of my user defined perl modules with different arguments. If it is required debug the issue, I can share the source code of $cmd API also.


In reply to Forking child process gives me an error: Attempt to free unreferenced scalar by srlbharu

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.