my $select = IO::Select->new( ); if (my $client = $server->accept( )) { open3($input,$output, undef, "cmd.exe"); $select->add($client); } $output->blocking(0); #fcntl($output, F_SETFL(), O_NONBLOCK()); while(1) { foreach( my ($current_socket) = $select->can_read(.5)) { last unless $current_socket; my $data; $current_socket->sysread($data,10,0); die unless $data; print $data, "\n"; } #we hit the timeout, so check the terminal for new data $output->sysread($data, 10, 0); print $data, "\n"; }