The question in my mind: If fork() is so troublesome on Windows, do we have an alternative?

For the (Program => "foo.exe") form, we can possibly avoid fork() altogether. http://rt.cpan.org/Public/Bug/Display.html?id=48715#txn-659406 includes some code that promises to work well.

For the (Program => \&foo) case, I don't know. Can Perl on Windows handle that well at all?

--
Rocco Caputo - rcap...@pobox.com


On Oct 12, 2009, at 10:54, Andreas Altergott wrote:

Hi,

Andrew Feren wrote:
Something like the following will give you better results.

      my $pid;
      if($pid = fork()) {
        print(FOUT "running ($pid)\n");
        wait();
      } else {
        open(FOR, '>>', 'C:\delme-kid.txt');
        thread();
        close(FOR);
        sleep(10);
        exit(0);
      }

Thanks for the suggestion, but I do not see why this should give better
results in combination with Win32::Daemon.  As already described the
service will get a termination request as soon as the child terminates, if you do use fork. Nevertheless I tested this and it did terminate the
service after one loop.

The termination request comes from the service control manager.
Probably it thinks the service terminated.  This doesn't make sense.
Especially because it tries to tell a service to stop, which in its
opinion did already stop.  Nevertheless it does so.

This behaviour happens only with fork AFAIK.


Regards,
Andreas


Reply via email to