[boulder.pm] Non-blocking IO on NT

William Atkinson CWA at DISC.com
Fri Feb 11 15:11:50 CST 2000


Greetings,

Has anyone gotten non-blocking reads from a pipe on NT to work?  Here's my
situation:

I have a program that I want to run locally from a perl script.  This perl
script will check to see if any output is available from that program and
print it.  Otherwise, it will continue to do the rest of what it's supposed
to be doing.  I've looked at the perl cookbook at recipe 7.13 but that
appeared to not work. From the Active State perl docs, it appears that
select and ioctl both only work on sockets.

Here's my "program", a shell script for emulating the real program:

------------
for i in 1 2 3 4 5 6 7 8 9 10; do
  echo "Hello number $i"
  sleep 1
done
------------

Here's the perl script:

------------
use strict;

use Fcntl;
use IO::File;
use IO::Handle;
use IO::Select;

use vars qw ($handle $buffer $select $flags @ready);

$handle = new IO::File;

if (! $handle->open ("qa.emu |"))
{
   print ("Error: Unable to open qa.emu\n");
}

$select = IO::Select->new();
$select->add($handle);

while (1)
{
   if (@ready = $select->can_read())
   {
      print ("got something to read\n");

   }
   else
   {
      print ("Nothing found to read\n");
   }
   if (@ready = $select->has_error(10))
   {
     print ("Something has an error\n");
   }   
}
$handle->close;

-------------
On linux it shows that there is something to read.  On NT, it constantly
says "Nothing found to read".  Not surprising since it appears that select
hasn't been implemented.

Thanks for any and all help.

Chip



More information about the Boulder-pm mailing list