my solution to lab5

This commit is contained in:
winPond
2019-07-11 19:40:12 +08:00
parent 1f043fb694
commit f78713349c
364 changed files with 8775 additions and 3249 deletions

30
lab/user/testkbd.c Normal file
View 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");
}
}