summaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-08 10:29:42 +0000
committerrsc <rsc>2007-08-08 10:29:42 +0000
commitf2f062da61eaca1dee675281c3b6b95d220ab322 (patch)
treeb2ad7ea8bf2359cf090d4ea1b8efa1969309ec6b /console.c
parent1cb183a987bb08cb0b25a6b8bd7e4011325c8ca9 (diff)
downloadxv6-labs-f2f062da61eaca1dee675281c3b6b95d220ab322.tar.gz
xv6-labs-f2f062da61eaca1dee675281c3b6b95d220ab322.tar.bz2
xv6-labs-f2f062da61eaca1dee675281c3b6b95d220ab322.zip
check p->killed for long-lived sleeps
Diffstat (limited to 'console.c')
-rw-r--r--console.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/console.c b/console.c
index ec3ecd0..cd52570 100644
--- a/console.c
+++ b/console.c
@@ -6,6 +6,7 @@
#include "dev.h"
#include "param.h"
#include "mmu.h"
+#include "proc.h"
struct spinlock console_lock;
int panicked = 0;
@@ -395,8 +396,13 @@ console_read(int minor, char *dst, int n)
target = n;
acquire(&kbd_lock);
while(n > 0){
- while(kbd_r == kbd_w)
+ while(kbd_r == kbd_w){
+ if(curproc[cpu()]->killed){
+ release(&kbd_lock);
+ return -1;
+ }
sleep(&kbd_r, &kbd_lock);
+ }
c = kbd_buf[kbd_r++];
if(c == C('D')){ // EOF
if(n < target){