Shell Lab: trace02

This commit is contained in:
cyp0633 2022-05-24 00:01:03 +08:00
parent c081d56e4a
commit dd323368d0
Signed by: cyp0633
GPG Key ID: E1BC508A994A5138
1 changed files with 5 additions and 1 deletions

View File

@ -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 */
}