Shell Lab: trace02
This commit is contained in:
parent
c081d56e4a
commit
dd323368d0
|
@ -177,7 +177,7 @@ void eval(char *cmdline)
|
|||
return;
|
||||
}
|
||||
// run external command
|
||||
if (!builtin_cmd(argv))
|
||||
if (!builtin_cmd(argv)) // built-in command is done in `builtin_cmd`
|
||||
{
|
||||
if ((pid = fork()) == 0) // this is child
|
||||
{
|
||||
|
@ -267,6 +267,10 @@ int parseline(const char *cmdline, char **argv)
|
|||
*/
|
||||
int builtin_cmd(char **argv)
|
||||
{
|
||||
if (strcmp(argv[0], "quit") == 0) // process quit command
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
return 0; /* not a builtin command */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue