in reply to Re: Non-blocking pipe write
in thread Non-blocking pipe write
but only one pipe write is successful and then the can_write check fails every time. Can you be more specific please?#!/usr/local/bin/perl use strict; use warnings; use IO::Handle; use IO::Select; my $handle; my $pid; if (!defined($pid = open($handle, "|-"))) { die "Fork failed: ".$!; } elsif ($pid == 0) { # Child sleep(5); exit 0; } else { # Parent $handle->autoflush(1); my $selector = IO::Select->new($handle); my $i = 0; do { if ($selector->can_write(0)) { print $handle "ABC\n"; print "PIPE write ".++$i."\n"; } else { print "PIPE cannot write\n"; } } while (1); }
|
|---|