Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Child process lingers after keyboard interrupt on Windows

by davido (Cardinal)
on Oct 11, 2018 at 06:18 UTC ( #1223851=note: print w/replies, xml ) Need Help??

in reply to Child process lingers after keyboard interrupt on Windows

Proc::Simple lets you instantiate forks that are managed by objects. You can set kill_on_destroy, causing a signal to be sent to the child when the managing object falls out of scope. It's only about 330 lines of code excluding comments and POD, and deals with tricky timing, zombies, and output redirection. So if you are unable to use external modules (that's another topic), you might just study it to determine what it does that you're not doing.

It came in handy for me on a recent project where I didn't want to invest a lot of time into reinventing the functionality that is provided on CPAN already.


  • Comment on Re: Child process lingers after keyboard interrupt on Windows

Replies are listed 'Best First'.
Re^2: Child process lingers after keyboard interrupt on Windows
by toughy (Acolyte) on Oct 20, 2018 at 10:55 UTC

    Thank you for the hint on this module.

    I believe Proc::Simple does not yet work on Windows. With Strawberry perl, installation from CPAN hangs during 'Building and testing Proc-Simple-1.32', and with ActivePerl from ActiveState the .ppm build failed on all Windows versions:

    I looked at the source on CPAN and what it does is fork() and exec(). I never tried it until now because I found it unintuitive that fork() will work properly on Windows, while IPC::Run will not, but I will try it. I do not like how Proc::Simple will exit(0); after exec() fails, I think that is a silent error and it can be dangerous.

    Thank you,
    Timothy Madden

      So trying to fork() I run into the this issue:

      When the pseudo-child process (really a new thread in the parent, see perl fork() emulation for Windows) reopens STDOUT, the parent STDOUT changes as well. Although perl documentation says the open handles are duplicated on emulated fork(), to prevent this issue.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2019-06-25 18:31 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (107 votes). Check out past polls.