srlbharu has asked for the wisdom of the Perl Monks concerning the following question:
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:
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.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 +"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Forking child process gives me an error: Attempt to free unreferenced scalar
by tmharish (Friar) on Feb 26, 2013 at 11:49 UTC | |
by srlbharu (Acolyte) on Feb 27, 2013 at 04:46 UTC | |
|
Re: Forking child process gives me an error: Attempt to free unreferenced scalar
by Corion (Patriarch) on Feb 27, 2013 at 07:51 UTC | |
by srlbharu (Acolyte) on Feb 27, 2013 at 10:48 UTC | |
by Corion (Patriarch) on Feb 27, 2013 at 12:11 UTC | |
|
Re: Forking child process gives me an error: Attempt to free unreferenced scalar
by Anonymous Monk on Jul 25, 2013 at 08:49 UTC |