Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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.

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2018-06-25 02:41 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.