Hello,

I've looked at this post and it is working fine: http://www.perlmonks.org/?node=471412.

I extended the example of BrowserUk so that I have a Cancel Button which then kills the process, but does not exit the application. And I have a start button which again starts it.

But to my problem. My process is unfortunately not that simple. It also creates subprocesses. Because I'm in a Win32 environment the only way I found to be sure that the process and its subprocesses are killed completely was to use Win32::Job.

But I don't know how to read from STDOUT while the process is running.

Here a code snippet without Win32::Job:

#!/usr/bin/perl use strict; use warnings; $|=1; open PROC, 'perl -le"$|=1; print and select(undef,undef,undef,0.1) for 1 .. 1 +000" |' or die $!; while( <PROC> ) { print $_; } close PROC;

How could I do the same with Win32::Job? The run function is blocking, so I think that I have to use the watch function. But already at the spawning I don't know how to fill the option "stdout" and how then to capture the output of the process while it is running when I try it with Win32::Job.

So to summarize my problem. I'm here in a Win32 environment. I have to be able to kill a process tree. But I also want to read STDOUT from the created process while it is running. What are my options? My idea was to use Win32::Job because it is then very easy to kill the entire process tree. But this lead me to the problem that I don't know how to read the output while the process is running.

Thank you alot for your help.


In reply to Read STDOUT from Win32::Job while process is running by Dirk80

Title:
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, details, 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, summary, 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.