Hello folks,

You invested quite a lot of time into my silly problems. :-)

I appreciate this.

@Athanasius: I changed the script accordingly. THX.

@tybalt89: Your solution looks very professional. I think I will borrow one or the other line in later versions (and come back with questions I guess).

But first I would like to understand why my code does not work as expected.

I am able to terminate child number one without problems, but the prog fails to restart the childs. On submitting SIGUSR1 to the parent, the child is killed as expected but the parent as well, as the sample output tells us:

Child two with PID 23317 received a message: 'Parent with process ID 2 +3314 for child two' Child one with PID 23316 received a message: 'Parent with process ID 2 +3314 for child one' The parent process with PID 23314 received a message: 'Child one with +PID 23316' The parent process with PID 23314 received a message: 'Child two with +PID 23317' DEBUG: $restart is 0 Child two with PID 23317 received a message: 'Parent with process ID 2 +3314 for child two' Child one with PID 23316 received a message: 'Parent with process ID 2 +3314 for child one' kill_and_restart: $restart is 0, $pid is 23316 kill_and_restart: $restart is 1

Repeating the test reveals that the program is NOT terminated at the same code line each time, e.g., I was able to get the message "(Re-)Starting ..." as the last line output.

But the expected behaviour is: parent keeps on running, kills the remaining child and gives birth to two new childs.

What do I miss out?

Cheers

Bloedian


In reply to Re: Influencing control flow using a signal handler by Bloehdian
in thread Influencing control flow using a signal handler by Bloehdian

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.