Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Win32: Starting and stopping processes (part 1)

by bojinlund (Curate)
on Oct 19, 2011 at 08:08 UTC ( #932326=note: print w/ replies, xml ) Need Help??


in reply to Win32: Starting and stopping processes (part 1)

In Win32 you should avoid using kill on forked processes.

From http://perl5.git.perl.org/perl.git/blob_plain/HEAD:/pod/perlfork.pod:

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.

...

=item kill()

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.

See also:


Comment on Re: Win32: Starting and stopping processes (part 1)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932326]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-09-02 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (21 votes), past polls