diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-03 01:49:40 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-03 01:51:42 +0100 |
commit | 202bdb553c2dc073f06105b12fbf0b2a8045069b (patch) | |
tree | 159e2bf3ccb0ba84b51aa811aa3cdc0d2aa12c19 /Userland/sh.cpp | |
parent | b59ce22fc5a3097544519eee7876e5f5d0656d4b (diff) | |
download | serenity-202bdb553c2dc073f06105b12fbf0b2a8045069b.zip |
Implemented sys$execve().
It's really crufty, but it basically works!
Diffstat (limited to 'Userland/sh.cpp')
-rw-r--r-- | Userland/sh.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Userland/sh.cpp b/Userland/sh.cpp index 6efa9ce4de..6c83c806e4 100644 --- a/Userland/sh.cpp +++ b/Userland/sh.cpp @@ -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; |