1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:07:35 +00:00

Implement waitpid() support for getting the waitee's exit code.

This commit is contained in:
Andreas Kling 2018-10-27 01:24:22 +02:00
parent 5cfeeede7c
commit ec07761d0f
7 changed files with 33 additions and 10 deletions

View file

@ -17,7 +17,8 @@ static void prompt()
static int sh_pwd(int, const char**)
{
printf("cwd: %s\n", g_cwd);
printf("%s\n", g_cwd);
return 0;
}
static int sh_cd(int argc, const char** argv)
@ -100,7 +101,14 @@ static int runcmd(char* cmd)
return 1;
}
// FIXME: waitpid should give us the spawned process's exit status
waitpid(ret);
int wstatus = 0;
waitpid(ret, &wstatus, 0);
if (WIFEXITED(wstatus)) {
//printf("Exited normally with status %d\n", WEXITSTATUS(wstatus));
} else {
printf("Exited abnormally\n");
}
return retval;
}