From 0ff17a00c83f34921b3d23f3e3ae999e4b1d7b8c Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 31 Mar 2013 17:28:29 +0200 Subject: [PATCH] Add O_NONBLOCK support to the kernel terminal. --- sortix/logterminal.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sortix/logterminal.cpp b/sortix/logterminal.cpp index 5c40777e..60b92444 100644 --- a/sortix/logterminal.cpp +++ b/sortix/logterminal.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2012. + Copyright(C) Jonas 'Sortie' Termansen 2012, 2013. This file is part of Sortix. @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -237,6 +238,8 @@ ssize_t LogTerminal::read(ioctx_t* ctx, uint8_t* userbuf, size_t count) bool blocking = !(termmode & TERMMODE_NONBLOCK); while ( left && !linebuffer.CanPop() && blocking && !numeofs ) { + if ( ctx->dflags & O_NONBLOCK ) + return errno = EWOULDBLOCK, -1; numwaiting++; bool abort = !kthread_cond_wait_signal(&datacond, &termlock); numwaiting--;