http://qs321.pair.com?node_id=759533


in reply to Re: Queries on open3
in thread Queries on open3

When I change my function as below and send "sleep 50" as a command, can_write is returning input file handle as one of the value. so it means it can be written ?. I expected it should not return input file handle since we cannot write into 'sleep' command.

Any Explanation or fix??

sub canSendInput { my $self = shift; my $pid = waitpid($self->{pid}, WNOHANG) my @ready = $self->{'selector'}->can_write(1);# Dumper(\@ready); }

Thanks,
Thiagu

Replies are listed 'Best First'.
Re^3: Queries on open3
by ikegami (Patriarch) on Apr 23, 2009 at 14:33 UTC

    I expected it should not return input file handle since we cannot write into 'sleep' command.

    You don't write "into a sleep command". You write into a pipe. As long as the pipe isn't full, it'll report that it can accept data.

    Perhaps you want Expect?

      I have used syswrite and checking the number of bytes written. also using SIGPIPE.