30 lines
564 B
C
30 lines
564 B
C
#include <err.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/wait.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
if (argc < 2)
|
|
err(1, "Not enough args");
|
|
|
|
int id = fork();
|
|
if (id < 0)
|
|
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);
|
|
printf("process exit status: %d\n", res);
|
|
// exit(res);
|
|
return res;
|
|
}
|
|
}
|