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

Implemented sys$execve().

It's really crufty, but it basically works!
This commit is contained in:
Andreas Kling 2018-11-03 01:49:40 +01:00
parent b59ce22fc5
commit 202bdb553c
9 changed files with 215 additions and 21 deletions

View file

@ -39,6 +39,32 @@ static int sh_fork(int, const char**)
return 0;
}
static int sh_fe(int, const char**)
{
pid_t pid = fork();
if (!pid) {
int rc = execve("/bin/ps", nullptr, nullptr);
if (rc < 0) {
perror("execve");
exit(1);
}
}
return 0;
}
static int sh_fef(int, const char**)
{
pid_t pid = fork();
if (!pid) {
int rc = execve("/bin/psx", nullptr, nullptr);
if (rc < 0) {
perror("execve");
exit(1);
}
}
return 0;
}
static int sh_exit(int, const char**)
{
printf("Good-bye!\n");
@ -101,7 +127,14 @@ static bool handle_builtin(int argc, const char** argv, int& retval)
retval = sh_exit(argc, argv);
return true;
}
if (!strcmp(argv[0], "fe")) {
retval = sh_fe(argc, argv);
return true;
}
if (!strcmp(argv[0], "fef")) {
retval = sh_fef(argc, argv);
return true;
}
if (!strcmp(argv[0], "fork")) {
retval = sh_fork(argc, argv);
return true;