diff options
[SP/P5] Added solutions to some exercises from today
1 files changed, 21 insertions, 0 deletions
| -rw-r--r-- | Year 3/System programming/Practicum5/ex5.c | 21 |
diff --git a/Year 3/System programming/Practicum5/ex5.c b/Year 3/System programming/Practicum5/ex5.c new file mode 100644 index 0000000..49fe3e2 --- /dev/null +++ b/Year 3/System programming/Practicum5/ex5.c @@ -0,0 +1,21 @@ +#include <fcntl.h> +#include <unistd.h> +#include <sys/wait.h> +#include <stdio.h> + +int main(int argc, char *argv[]) { + pid_t f = fork(); + if (f < 0) { + perror("fork"); + return 1; + } + + if (f == 0) { + execvp(argv[1], argv + 1); + } + else { + int status = -2; + wait(&status); + printf("Child: %d\tExit: %d\n", f, status); + } +} |
