diff --git a/ports/src/noux/io_channel.h b/ports/src/noux/io_channel.h index e473cb7a8e..c947eab449 100644 --- a/ports/src/noux/io_channel.h +++ b/ports/src/noux/io_channel.h @@ -70,6 +70,11 @@ namespace Noux { virtual bool check_unblock(bool rd, bool wr, bool ex) const { return false; } + /** + * Return true if the channel is set to non-blocking mode + */ + virtual bool is_nonblocking() { return false; } + /** * Register blocker for getting waked up on an I/O channel event * diff --git a/ports/src/noux/main.cc b/ports/src/noux/main.cc index a4aa76e333..da0db0dcd5 100644 --- a/ports/src/noux/main.cc +++ b/ports/src/noux/main.cc @@ -140,8 +140,9 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc) Shared_pointer io = _lookup_channel(_sysio->write_in.fd); - if (!io->check_unblock(false, true, false)) - _block_for_io_channel(io); + if (!io->is_nonblocking()) + if (!io->check_unblock(false, true, false)) + _block_for_io_channel(io); /* * 'io->write' is expected to update 'write_out.count' @@ -156,8 +157,9 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc) { Shared_pointer io = _lookup_channel(_sysio->read_in.fd); - while (!io->check_unblock(true, false, false)) - _block_for_io_channel(io); + if (!io->is_nonblocking()) + while (!io->check_unblock(true, false, false)) + _block_for_io_channel(io); io->read(_sysio); return true;