This commit is contained in:
benstrb 2025-10-04 12:38:50 +02:00
commit 122205c0d1
2 changed files with 24 additions and 0 deletions

BIN
shell Executable file

Binary file not shown.

24
shell.c Normal file
View file

@ -0,0 +1,24 @@
#include <sys/wait.h>
#include <unistd.h>
int main() {
char command[255];
while (1) {
write(1, "benag@shell > ", 14);
int count = read(0, command, 255);
// /bin/ls\n -> /bin/ls\0
command[count - 1] = 0;
char *args[] = {command, NULL};
pid_t fork_result = fork();
if (fork_result == 0) {
execve(command, args, 0);
break;
} else {
siginfo_t info;
waitid(P_ALL, 0, &info, WEXITED);
}
}
}