Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update:</strong> Based on your comments, I get the feeling that your programs are not examples of best practices on Linux or Windows. However, I am sure, when reading the documentation for <code>Win32::Process</code>, you noticed that you can call the <code>Kill</code> method on the process to terminate it. So, I changed the example below to do that.</p> <p>Your chances of getting useful help increase exponentially if you provide real code. Here are the arguments to <code>Win32::Process::Create</code>:</p> <p><strong><code>$iflags</code>:</strong> flag: inherit calling processes handles or not</p> <p>Now, I am not sure if you are trying to capture the <code>STDOUT</code> of the second process or if you are trying to have its <code>STDOUT</code> output show up in the same console as the parent.</p> <p>If the latter, then the following scripts illustrate one way of doing that:</p> <h3>parent.pl</h3> <pre><code>#!/usr/bin/perl use strict; use warnings; use Win32; use Win32::Process; $| = 1; my $p; print "Starting child process ... \n"; Win32::Process::Create( $p, 'c:/opt/perl/bin/perl.exe', 'perl hello.pl', 1, NORMAL_PRIORITY_CLASS, '.', ) or die Win32::FormatMessage( Win32::GetLastError() ); print "Waiting three seconds before killing 'hello.pl'\n"; for (1 .. 3) { print; sleep 1; } $p-&gt;Kill(0) or die "Cannot kill '$p'"; </code></pre> <h3>hello.pl</h3> <pre><code>#!/usr/bin/perl $| = 1; print "Hello World\n"; print "Sleeping 1000 seconds\n"; for (1 .. 1000) { sleep 1; print '.'; } </code></pre> <h3>Output:</h3> <pre> Starting child process ... Waiting three seconds before killing 'hello.pl' 1Hello World Sleeping 1000 seconds 2.3. </pre> <p>Now, <strong>I am still not sure why you are using <code>Win32::Process</code></strong>. Unless there is a specific reason to tie your script to <code>Win32</code>, I would recommend using standard Perl facilities. For example, read <a href="http://perldoc.perl.org/functions/open.html" rel="nofollow noreferrer"><code>perldoc -f open</code></a> and <a href="http://perldoc.perl.org/perlipc.html" rel="nofollow noreferrer"><code>perldoc perlipc</code></a> (see esp. <a href="http://perldoc.perl.org/perlipc.html#Using-open%28%29-for-IPC" rel="nofollow noreferrer"><em>Using open for IPC</em></a>).</p> <p>Explain your question better to get answers that address your particular situation rather than generalities.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload