shell can launch another user processgit add .git add .!

This commit is contained in:
2026-07-12 20:13:13 -05:00
parent e2ab130324
commit 5c7febbbf0
15 changed files with 403 additions and 220 deletions

View File

@@ -1,3 +1,4 @@
#include "syscall.h"
#include <unistd.h>
#include <stdio.h>
#include <string.h>
@@ -7,6 +8,10 @@ const char* shell_prompt = "rocksh> ";
char buf[256];
size_t buf_offset = 0;
char path[256];
const char* bin_dir = "/bin/";
void parse_cmd() {
if (strcmp(buf, "exit") == 0) {
printf("bye!\n");
@@ -15,7 +20,25 @@ void parse_cmd() {
if (strcmp(buf, "motd") == 0) {
printf("rockos is the best!\n");
return;
}
// need a strcat
char* dst = path;
strcpy(dst, bin_dir);
dst = path + strlen(bin_dir);
strcpy(dst, buf);
int pid = fork();
if (pid == 0) {
if (!exec(path)) {
return;
}
}
int status;
waitpid(pid, &status);
printf("process exited with status %d\n", status);
}
void reset() {