Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi, I'm trying to port a complex application from FreeBSD to Win32, and am having all kinds of problems with starting and stopping processes. Before getting into specific questions, let me describe the program. Perhaps someone has some general guidelines or ideas for starting and stopping this monster.
SUPERVISOR.PL ------------- print PIDFILE "$$\r\n"; $SIG{QUIT} = \%SHUTDOWN; fork() if child, exec ctrlman.pl fork() if child, exec pidman.pl fork() if child, exec progman.pl fork() if child, exec webman.pl while (1) { do stuff } exit; sub SHUTDOWN { kill 3, CTRLMAN_pid # pid saved from the fork kill 3, PIDMAN_pid kill 3, PROGMAN_pid kill 3, WEBMAN_pid }

Supervisor and his four children then talk to each other through DGRAM sockets. One big happy family.

Each programX has its own SHUTDOWN - SIG{QUIT} handler - which does an orderly shutdown, closing sockets and things before exiting.

In freeBSD:
I start with csh> perl supervisor.pl
I stop with csh> kill -3 `cat PIDFILE`
The supervisor propagates the QUIT to the other processes, and everybody shuts down nicely.

19:28:39:982 SUPERVISOR: Shutdown started^M 19:28:39:983 SUPERVISOR: Killing Ctrlman Pidman Progman Webman^M 19:28:39:983 SUPERVISOR: Waiting for processes to die^M 19:28:39:984 CTRLMAN: Shutdown started^M 19:28:39:985 CTRLMAN: Shutdown complete^M 19:28:39:990 PIDMAN: Shutdown started^M 19:28:39:991 PIDMAN: Shutdown complete^M 19:28:39:994 PROGMAN: Shutdown started^M 19:28:39:995 PROGMAN: Shutdown complete^M 19:28:39:997 WEBMAN: Shutdown started^M 19:28:39:998 WEBMAN: Shutdown complete^M 19:28:40:001 supervisor: reaped 17752 exit 0 signal 0 dump 0^M 19:28:40:002 SUPERVISOR: Shutdown complete^M

Everything works so nicely in Unix...

NOT so in Win32.
Windows doesn't really have signals or signal handlers, so the whole signal idea pretty much goes out the window (pun intended), although PERL does implement some limited signal handling capabilities.

If anyone has some general suggestions for managing startup and shutdown of such a system, I'd be glad to hear them.

I've got a ton of questions, so point me in the right direction now, and save yourself a ton of questions later.

Thanks,
Dave


In reply to Win32: Starting and stopping processes (part 1) by hennesse

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, 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, 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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (2)
    As of 2020-11-30 07:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?