This commit is contained in:
Guillem George 2025-10-23 17:36:07 +02:00
commit 62ece126f9
2 changed files with 26 additions and 0 deletions

BIN
microshell/a.out Executable file

Binary file not shown.

26
microshell/microshell.c Normal file
View file

@ -0,0 +1,26 @@
#include <err.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main(int argc, char **argv)
{
if (argc < 2)
errx(1, "Not enough args");
int id = fork();
if (id < 0)
errx(1, "Cannot fork");
if (id == 0)
{
int res = 0;
wait(&res);
return res;
}
else
{
int res = execl("/bin/sh", "supershell", "-c", argv[1], NULL);
exit(res);
}
}