bugfix: exec执行的文件不存在时,自动退出进程。

This commit is contained in:
fslongjin
2022-06-09 21:56:32 +08:00
parent f37a090989
commit 2a47569473
16 changed files with 100 additions and 103 deletions

View File

@ -1,5 +1,5 @@
#include <libc/stdio.h>
#include<libc/stdlib.h>
void print_ascii_logo()
{
printf(" ____ ___ ____ \n");
@ -25,7 +25,7 @@ int main()
// printf("Hello World!\n");
print_ascii_logo();
print_copyright();
exit(1);
exit(0);
while (1)
;
}

View File

@ -381,7 +381,7 @@ int shell_cmd_exec(int argc, char **argv)
// 子进程
int path_len = 0;
char *file_path = get_target_filepath(argv[1], &path_len);
printf("before execv, path=%s, argc=%d\n", file_path, argc);
// printf("before execv, path=%s, argc=%d\n", file_path, argc);
execv(file_path, argv);
free(argv);
while (1)
@ -390,7 +390,7 @@ int shell_cmd_exec(int argc, char **argv)
}
else
{
printf("parent process wait for pid:[ %d ]\n", pid);
// printf("parent process wait for pid:[ %d ]\n", pid);
waitpid(pid, &retval, 0);
printf("parent process wait pid [ %d ], exit code=%d\n", pid, retval);