Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Stop Command In Perl

by monsoon (Pilgrim)
on Jul 12, 2012 at 16:43 UTC ( #981437=note: print w/ replies, xml ) Need Help??

in reply to Stop Command In Perl

Why not just exit the loop with last and close the handle right after? I don't get though why you need a loop at all in this case.

Comment on Re: Stop Command In Perl
Replies are listed 'Best First'.
Re^2: Stop Command In Perl
by anshumangoyal (Scribe) on Jul 12, 2012 at 17:38 UTC
    Does closing the handler also kills the command?

      It would send a SIGPIPE which may or may not stop the command. This stuff is rather system specific and I'm not sure if what's the default on Windows. Just try.

      Otherwise if you really need a Ctrl-C to be sent: this form of open() returns the child's PID so you can use kill 2, $pid to send the signal.

        I think windows doesn't quite respect 'kill'. This (run on Windows 7 Professional, ActivePerl v5.12.4)
        perl -e "$pid = open PIPE, '-|', 'echo one two';$/=' '; while (<PIPE>) +{ print; kill 2, $pid}"

        one two

        But this
        perl -e "$pid = open PIPE, '-|', 'echo one two';$/=' '; while (<PIPE>) +{ print; close PIPE}"


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2015-11-27 13:29 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (729 votes), past polls