hennesse has asked for the wisdom of the Perl Monks concerning the following question:

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 fork() if child, exec fork() if child, exec fork() if child, exec 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
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.