diff --git a/src/system/linux/linux.c b/src/system/linux/linux.c index bdab0c3..4444cc1 100644 --- a/src/system/linux/linux.c +++ b/src/system/linux/linux.c @@ -194,26 +194,28 @@ int msh_execute(char *cmd, char **args) { msh_linux_setup_signals(); - ret = (SIZE_TYPE)SYSCALL(wait4, fork, &status, 0, &ru); + SYSCALL(wait4, fork, &status, 0, &ru); SYSCALL(kill, fork, SIGKILL); SYSCALL(write, 1, "\r", 2); - msh_linux_start_input_capture(); - char pid_str[16]; itoa(fork, pid_str, 10); if (WIFSIGNALED(status)) { - msh_print_strings(pid_str, "\t", (char *)signal_table[WTERMSIG(status)], - "\t", cmd, "\r\n", 0); - return WTERMSIG(status); + msh_print_strings(pid_str, " ", (char *)signal_table[WTERMSIG(status)], + " ", cmd, "\n\r", 0); + ret = WTERMSIG(status); } else if (WIFSTOPPED(status)) { - msh_print_strings(pid_str, "\tstopped\t", cmd, "\r\n", 0); + msh_print_strings(pid_str, "\tstopped\t", cmd, "\n\r", 0); + ret = WEXITSTATUS(status); } else { - return WEXITSTATUS(status); + ret = WEXITSTATUS(status); } + + msh_linux_start_input_capture(); + return ret; } return 0; };