Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://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":



  • 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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-18 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found