Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

However, forked children don't know what their parent is doing nor does the parent know what it's children are doing with the exception of when the child exits, right?

This is totally wrong. Read perlipc

Here is code that uses Hang Up signal to perform the required parent/child IPC:

[root@id3 root]# cat #!/usr/bin/perl $|++; $SIG{HUP} = sub { do_end_vote() }; while ( 1 ) { my $event = check_for_event(); if ( $event ) { do_start_vote(); if ( fork() == 0 ) { # this is kid sleep 10; local $SIG{HUP} = sub { print "Child caught HUP!" }; # signal parent (and kid) kill HUP, $0; exit 0; } } # this is parent sleep 1; print "."; } sub do_start_vote { print "Begin" } sub do_end_vote{ print "End!" } # generate one event every 20 calls to this sub for testing sub check_for_event{ $a++; return $a%20 == 0 ? 1 : 0 } [root@id3 root]# ./ ...................Begin.........Child caught HUP!End!...........Begin +.........Child caught HUP!End!...........Begin.... [root@id3 root]#




In reply to Re: Re: Re: Re: Re: 'better mousetrap': how to perform timed event by tachyon
in thread 'better mousetrap': how to perform timed event by snafu

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2022-10-05 05:43 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (20 votes). Check out past polls.