in reply to Perl Background processes in Windows

I recently had to write a quick script that I wanted to run in the background indefinitely in Windows.

Tried to find a solution with Win32::Process, but whenever I killed the parent process the child would die as well.

Anyway, I went ahead and ended up doing this:

fork() ? exit(): exec("$cmd $args");

I know Windows implements fork differently which probably explains an odd bug where the parent process hangs instead of exiting. This is fine, I kill it manually. The end result - a headless, background child process - still works fine.

Annoying side effect of Perl's fork() implementation on Windows, the PID is not valid. So I cannot keep track of it to kill the process later.

Actually, I'm a little baffled that this method works. Isn't Perl fork() on Windows supposed to simulate another process, not actually create another one? I believe it has something to do with the nature of exec().