diff --git a/yeeshell.c b/yeeshell.c index 3e764db..f770542 100644 --- a/yeeshell.c +++ b/yeeshell.c @@ -400,22 +400,17 @@ int builtin_history(char **args) int builtin_mytop() { pid_t pid; - int cputimemode = 1; - if ((pid = fork()) < 0) - { - printf("fork error\n"); - return -1; - } - - getkinfo(); - mytop_memory(); - get_procs(); - if (prev_proc == NULL) + if (pid == 0) { + int cputimemode = 1; + getkinfo(); + mytop_memory(); get_procs(); + if (prev_proc == NULL) + get_procs(); + print_procs(prev_proc, proc, cputimemode); + exit(1); } - print_procs(prev_proc, proc, cputimemode); - exit(0); } void mytop_memory()