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.