Update:
This turns out to be a problem in POE 1.006, that is fixed in POE 1.007. I've just updated to 1.007, and now I'm seeing the "dir" output in the console window. Running under 1.006 I didn't see that. Thanks to all for the help!

Helpful Monks-

I wish to use POE::Wheel::Run along with Tk to do some things.

As a starting point, I always like to grab the example code from the CPAN docs and start hacking on that.

The unmodified CPAN code runs fine as is on my various unix platforms. To get it to run under Activestate perl, I simply changed the Program line to be:

Program => 'dir',

and it also works fine.

The next step was to try to install the use Tk; at the beginning, so that POE could try to configure itself for the Tk event loop. Simply adding use Tk; before use POE; caused the program to fail on Activestate Perl (again it works fine on unix platforms).

Having a small bit of experience with these problems, I also tried use POE qw (Loop::TkActiveState); with no luck either. In addition, I did notice a POE::Wheel::Run::Win32, which I installed from Activestate and tried, but it failed even worse.

The script fails, by briefly flashing a blank Tk window, then exiting. The only output I see is the line "Child pid -2564 started as wheel 1."

Any help or pointers is appreciated!

Thanks

-Craig

PS - I'm attaching the code that I'm using in the following readmore tags, for completeness.

use warnings; use strict; use Tk; # Fails under Activestate, when this is uncommented #use POE qw( Loop::TkActiveState ); use POE; use POE::Wheel::Run; POE::Session->create( inline_states => { _start => \&on_start, got_child_stdout => \&on_child_stdout, got_child_stderr => \&on_child_stderr, got_child_close => \&on_child_close, got_child_signal => \&on_child_signal, } ); POE::Kernel->run(); exit 0; sub on_start { my $child = POE::Wheel::Run->new( Program => 'dir', StdoutEvent => "got_child_stdout", StderrEvent => "got_child_stderr", CloseEvent => "got_child_close", ); $_[KERNEL]->sig_child($child->PID, "got_child_signal"); # Wheel events include the wheel's ID. $_[HEAP]{children_by_wid}{$child->ID} = $child; # Signal events include the process ID. $_[HEAP]{children_by_pid}{$child->PID} = $child; print( "Child pid ", $child->PID, " started as wheel ", $child->ID, ".\n" ); } # Wheel event, including the wheel's ID. sub on_child_stdout { my ($stdout_line, $wheel_id) = @_[ARG0, ARG1]; my $child = $_[HEAP]{children_by_wid}{$wheel_id}; print "pid ", $child->PID, " STDOUT: $stdout_line\n"; } # Wheel event, including the wheel's ID. sub on_child_stderr { my ($stderr_line, $wheel_id) = @_[ARG0, ARG1]; my $child = $_[HEAP]{children_by_wid}{$wheel_id}; print "pid ", $child->PID, " STDERR: $stderr_line\n"; } # Wheel event, including the wheel's ID. sub on_child_close { my $wheel_id = $_[ARG0]; my $child = delete $_[HEAP]{children_by_wid}{$wheel_id}; # May have been reaped by on_child_signal(). unless (defined $child) { print "wid $wheel_id closed all pipes.\n"; return; } print "pid ", $child->PID, " closed all pipes.\n"; delete $_[HEAP]{children_by_pid}{$child->PID}; } sub on_child_signal { print "pid $_[ARG1] exited with status $_[ARG2].\n"; my $child = delete $_[HEAP]{children_by_pid}{$_[ARG1]}; # May have been reaped by on_child_close(). return unless defined $child; delete $_[HEAP]{children_by_wid}{$child->ID}; }

In reply to POE::Wheel::Run & Tk Problems - Solved by cmv

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.