init: init nachos hw01, should pass jenkins os_group_20_hw job but fail on os_group_20_ta job
This commit is contained in:
35
code/test/shell.c
Normal file
35
code/test/shell.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "syscall.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
SpaceId newProc;
|
||||
OpenFileId input = ConsoleInput;
|
||||
OpenFileId output = ConsoleOutput;
|
||||
char prompt[2], ch, buffer[60];
|
||||
int i;
|
||||
|
||||
prompt[0] = '-';
|
||||
prompt[1] = '-';
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
Write(prompt, 2, output);
|
||||
|
||||
i = 0;
|
||||
|
||||
do {
|
||||
|
||||
Read(&buffer[i], 1, input);
|
||||
|
||||
} while( buffer[i++] != '\n' );
|
||||
|
||||
buffer[--i] = '\0';
|
||||
|
||||
if( i > 0 ) {
|
||||
newProc = Exec(buffer);
|
||||
Join(newProc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user