http://www.perlmonks.org?node_id=467785

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

This applies to windows with active state perl.

Let's say I have a service on my computer, it just listens on a particular port and does stuff. I want to start it in the background, and then later on (say ten seconds later) stop it. I figured out how to start it from reading the faq.

use strict; use warnings; my $result = system("C:\\Programme\\service.exe &"); print "sleeping"; sleep(3); die;

The thing is, this never dies, because the command never returns... because it is a service, it just sits there and listens and listens and listens.

But now how do I write something that starts, waits ten seconds, and stops? I guess the answer must be something along the lines of you start a separate thread that gets the process id, which returns it to the parent process, which then waits ten seconds and kills the child process... except that I have no idea how to do that.

In addition to an answer of this particular question, I would be much obliged if someone could point me towards a tutorial about the basics of systems programming. Thanks!