Thanks to all who responded to my earlier message.

My problem has evolved somewhat and I have some new questions :)

What I have now is the desire to update a hash value from within a CHLD
signal handler subroutine.

That is, a main loop is constantly watching the values of a set of hash
keys.  When one is available (e.g. value of 0, all initialized as such
at startup), a process is forked off.  

The parent code block of the fork now updates one of the key value pairs
with the PID of the forked child  (the keys are machine names fyi).

What I'd *love* to be able to do, is in the associated CHLD handling
subroutine (lifted from the perl book), react to the child finishing and
update that hash key->value back to 0 so the main loop can now reuse
that machine!


What I figure is if I could pass a reference to the hash into the
handler subroutine, then I could operate on the right data, but I can't
figure out 1) if this is even legal, 2) how to pass a ref into a handler
subroutine.

I've tried declaring a ref to the hash as part of the sig handler
installer:
$SIG{CHLD} = \&REAPER ( $machine_state_db_ref) ;
..this doesn't seem to work.

Again, the handler does fire, but it doesn't appear to be updating the
hash.

Hope this all makes sense.

Cheers,

-M

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to