Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Well blow me down, BrowserUK is correct. I've never gotten alarm() to work reliably on Windows - perhaps because I'm not that versed in Signals and didn't know what I was doing or was trying on a system call without the eval/die as described in alarm; however, alarm() added in my original script works:

use strict; use warnings; my $pid = open(my $fileHandler, '-|', "./test.exe" ); my $DONE = 0; $SIG{ALRM} = sub { $DONE = 1 }; alarm 2; while (<$fileHandler>) { print "$_\r"; # \r to not overrun output screen buffer last if ($DONE) } print "\nTimeout! - Time to kill pid: $pid\n"

And the output

VinsWorldcom@C:\Users\VinsWorldcom\tmp> TimeThis TimeThis : Command Line : TimeThis : Start Time : Fri Oct 12 13:01:09 2012 114601 Timeout! - Time to kill pid: 4700 TimeThis : Command Line : TimeThis : Start Time : Fri Oct 12 13:01:09 2012 TimeThis : End Time : Fri Oct 12 13:01:12 2012 TimeThis : Elapsed Time : 00:00:02.454

In reply to Re^3: Windows run an exe print its output and cut it off after a time by VinsWorldcom
in thread Windows run an exe print its output and cut it off after a time by anshumangoyal

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [virtualsue]: The person who talks to me on it the most *hates* Perl but she hates everything
    [virtualsue]: If anyone is interested, ping me an email address for an invitation.
    [virtualsue]: I welcome any talktaive people who do not mind using a propietary walled-garden service for free
    [virtualsue]: or even proprietary
    [virtualsue]: we talk about programming and music and stuff
    herveus waves to virtualsue

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (13)
    As of 2017-09-26 14:00 GMT
    Find Nodes?
      Voting Booth?
      During the recent solar eclipse, I:

      Results (296 votes). Check out past polls.