'
This commit is contained in:
commit
09a42aa179
2 changed files with 26 additions and 0 deletions
BIN
microshell/a.out
Executable file
BIN
microshell/a.out
Executable file
Binary file not shown.
26
microshell/microshell.c
Normal file
26
microshell/microshell.c
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue