mirror of
https://github.com/SmallPond/MIT6.828_OS.git
synced 2026-04-29 05:11:07 +08:00
my solution to lab5
This commit is contained in:
30
lab/user/testkbd.c
Normal file
30
lab/user/testkbd.c
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#include <inc/lib.h>
|
||||
|
||||
void
|
||||
umain(int argc, char **argv)
|
||||
{
|
||||
int i, r;
|
||||
|
||||
// Spin for a bit to let the console quiet
|
||||
for (i = 0; i < 10; ++i)
|
||||
sys_yield();
|
||||
|
||||
close(0);
|
||||
if ((r = opencons()) < 0)
|
||||
panic("opencons: %e", r);
|
||||
if (r != 0)
|
||||
panic("first opencons used fd %d", r);
|
||||
if ((r = dup(0, 1)) < 0)
|
||||
panic("dup: %e", r);
|
||||
|
||||
for(;;){
|
||||
char *buf;
|
||||
|
||||
buf = readline("Type a line: ");
|
||||
if (buf != NULL)
|
||||
fprintf(1, "%s\n", buf);
|
||||
else
|
||||
fprintf(1, "(end of file received)\n");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user