[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



  $pids{$pid}{'name'} = $name;
  $pids{$pid}{'pid'} = $pid;
  $pids{$pid}{'cmd'}  = $cmd;
  $pids{$pid}{'args'} = "@args";

Child handler:
    if($CHILD == 1) {
      my $child_pid = wait;
      my $status = $?;
      foreach my $ref (sort keys %pids) {
        if($child_pid == $ref) {
          print "Process $pids{$ref}{'name'} exited!\n";
          print "  CMD: $pids{$ref}{'cmd'} $pids{$ref}{'args'}\n";
          print "  Restarting $pids{$ref}{'cmd'}\n";
          my @args = split(/\s/, $pids{$ref}{'args'});
          start_program "/opt/SAM/logs/$pids{$ref}{'name'}.log",
            "$pids{$ref}{'name'}", "$pids{$ref}{'cmd'}", @args;
        }
      }
      $CHILD = 0;
    }

I simply use split to rebuild an array then execute the start_program
function with the correct arguments;



On Fri, 2004-12-31 at 09:28, Christopher Fowler wrote:
> What is the best way to attach an array to a hash.  I know I've asked
> this question before but I just can not remember how to do it.  
> 
> Here is sample:
> 
>   $pids{$pid}{'name'} = $name;
>   $pids{$pid}{'pid'} = $pid;
>   $pids{$pid}{'cmd'}  = $cmd;
>   $pids{$pid}{'args'} = @args;
> 
> This is part of an init.d program that stays running to make sure that
> some programs never terminate.  If they do it will be responsible for
> logging an error and then restarting that proggie.  It will keep Java
> RMI program running.
> 
> Child Handler:
> 
>     if($CHILD == 1) {
>       my $child_pid = wait;
>       my $status = $?;
>       foreach my $ref (sort keys %pids) {
>         if($child_pid == $ref) {
>           print "Process $pids{$ref}{'name'} exited!\n";
>           print "  CMD: $pids{$ref}{'cmd'} $pids{$ref}{'args'}\n";
>         }
>       }
>       $CHILD = 0;
>     }
> 
> 
> 
> Thanks,
> Chris
> 
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
&gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00987" href="msg00987.html">[ale] attaching an array to a hash</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00990.html">[ale] New Topic</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00992.html">[ale] New Topic</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00987.html">[ale] attaching an array to a hash</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00993.html">[ale] Publicly available secondary DNS servers</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00991"><strong>Date</strong></a></li>
<li><a href="threads.html#00991"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>