E
Ed W
I have been staring at this for a day now (durr), but I just can't see what
is wrong with this code: (apart from poor coding style, but it's a
snippet...)
It's running under windows XP with activestate perl 5.6.1. However, the
code below always returns an empty array from the select call? There is
definitely something to read from the filehandle, if I comment out the IF
statement, then I happily get the first 10 bytes read from my other perl
program
The bigger picture is that the other perl script is a long running program
which occasionally returns output to stdout. I want the wrapper program to
do non-blocking IO to read stdout from the child process, however, select
doesn't appear to be letting me know that there is stuff to read, and simply
doing sysread works, but then blocks as soon as there is nothing left to
read (it unblocks occasionally when more data arrives)
The even larger picture is that I was to log this stuff in a text box in TK,
but I haven't found the $window->fileevent stuff to work for either tcp
sockets, or filehandles, this seems to be a known issue with Win32 though?
In the meantime I just want something running in the idle loop in order to
get something working today and I will re-work it later in something better.
Thanks for any pointers
Ed W
use IO::File;
use IO::Select;
my $H = IO::File->new("multi-client16.pl |");
$H->blocking(0);
$s = IO::Select->new();
$s->add($H);
my @readable = $s->can_read(0);
if (@readable) {
# We never get here? Why?
$H->sysread($ARG, 10);
print $ARG;
}
is wrong with this code: (apart from poor coding style, but it's a
snippet...)
It's running under windows XP with activestate perl 5.6.1. However, the
code below always returns an empty array from the select call? There is
definitely something to read from the filehandle, if I comment out the IF
statement, then I happily get the first 10 bytes read from my other perl
program
The bigger picture is that the other perl script is a long running program
which occasionally returns output to stdout. I want the wrapper program to
do non-blocking IO to read stdout from the child process, however, select
doesn't appear to be letting me know that there is stuff to read, and simply
doing sysread works, but then blocks as soon as there is nothing left to
read (it unblocks occasionally when more data arrives)
The even larger picture is that I was to log this stuff in a text box in TK,
but I haven't found the $window->fileevent stuff to work for either tcp
sockets, or filehandles, this seems to be a known issue with Win32 though?
In the meantime I just want something running in the idle loop in order to
get something working today and I will re-work it later in something better.
Thanks for any pointers
Ed W
use IO::File;
use IO::Select;
my $H = IO::File->new("multi-client16.pl |");
$H->blocking(0);
$s = IO::Select->new();
$s->add($H);
my @readable = $s->can_read(0);
if (@readable) {
# We never get here? Why?
$H->sysread($ARG, 10);
print $ARG;
}