in reply to Win32: Starting and stopping processes (part 1)
In Win32 you should avoid using kill on forked processes.
perlfork - Perl's fork() emulation
The fork() emulation is implemented at the level of the Perl interpreter. What this means in general is that running fork() will actually clone the running interpreter and all its state, and run the cloned interpreter in a separate thread, beginning execution in the new thread just after the point where the fork() was called in the parent. We will refer to the thread that implements this child "process" as the pseudo-process.
C<kill('KILL', ...)> can be used to terminate a pseudo-process by passing it the ID returned by fork(). The outcome of kill on a pseudo-process is unpredictable and it should not be used except under dire circumstances, because the operating system may not guarantee integrity of the process resources when a running thread is terminated. The process which implements the pseudo-processes can be blocked and the Perl interpreter hangs. Note that using C<kill('KILL', ...)> on a pseudo-process() may typically cause memory leaks, because the thread that implements the pseudo-process does not get a chance to clean up its resources.
As the terminated thread runs inside the same process as the controlling thread, it is always possible that the controlling thread will get damaged by this action.
- Proposal how to make modules using fork more portable
- Bug #66437 for Test-TCP: Tests are blocking in Windows 7 https://rt.cpan.org/Public/Bug/Display.html?id=66437
- Bug #66016 for Test-TCP: Tests fail on Windows (even when they pass?) https://rt.cpan.org/Public/Bug/Display.html?id=66016