projects
/
pintos-anon
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Add PTSPAN.
[pintos-anon]
/
src
/
tests
/
userprog
/
shell.c
1
#include <stdio.h>
2
#include <syscall.h>
3
4
int
5
main (void)
6
{
7
for (;;)
8
{
9
char command[80], *cp;
10
11
/* Prompt. */
12
printf ("--");
13
14
/* Read and echo command. */
15
for (cp = command; cp < command + sizeof command - 1; cp++)
16
{
17
read (STDIN_FILENO, cp, 1);
18
putchar (*cp);
19
if (*cp == '\n')
20
break;
21
}
22
*cp = '\0';
23
24
/* Execute command. */
25
if (cp > command)
26
{
27
pid_t pid = exec (command);
28
if (pid != PID_ERROR)
29
join (pid);
30
else
31
printf ("exec failed\n");
32
}
33
}
34
}