[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Fri Dec 31 10:30:05 2004 -->
- <!--x-from-r13: psbjyre ng bhgcbfgfragvary.pbz (Quevfgbcure Tbjyre) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] attaching an array to a hash -->
- <li><em>date</em>: Fri Dec 31 10:30:05 2004</li>
- <li><em>from</em>: cfowler at outpostsentinel.com (Christopher Fowler)</li>
- <li><em>in-reply-to</em>: <<a href="msg00987.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00987.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] attaching an array to a hash</li>
$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
> <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>