'
This commit is contained in:
parent
62ece126f9
commit
eac570d6f5
4 changed files with 56 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -6,21 +7,24 @@
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2)
|
||||
errx(1, "Not enough args");
|
||||
err(1, "Not enough args");
|
||||
|
||||
int id = fork();
|
||||
if (id < 0)
|
||||
errx(1, "Cannot fork");
|
||||
err(1, "Cannot fork");
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
int res = 0;
|
||||
wait(&res);
|
||||
// printf("%d\n", res);
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
int res = execl("/bin/sh", "supershell", "-c", argv[1], NULL);
|
||||
exit(res);
|
||||
printf("process exit status: %d\n", res);
|
||||
// exit(res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue