minimake/microshell/microshell.c
Guillem George 62ece126f9 '
2025-10-23 17:36:07 +02:00

26 lines
442 B
C

#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);
}
}