in reply to Use another script to check bacground process

Think about a different approach. Windows is a painful environment, but it has an API for background processes. They are called services, and it is possible to write services in Perl. Services can be monitored easily and with a predefined API. No need to re-invent the wheel.

On a Unix system, I would (and do) use daemontools to run and monitor "background" processes, with much less pain. Should a process exit unexpectedly, daemontools will report that and restart the process (unless configured otherwise), thanks to SIGCHLD.

Windows has no signals, not even SIGCHLD, but you can (painfully) construct similar mechanisms, typically using atoms, semaphores, and other API functions not originally intended to do so.

The important trick in both cases is that the script starter does not exit, but keeps track of its child processes. With daemontools, you don't even start the child process, but instead tell the monitor to start (or stop or signal) the script. This is very similar to how Windows Services behave.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re: Use another script to check bacground process