Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practicum5 / ex5.c
blob: 49fe3e2e229cb6a6cfb840e8609bc957aa057f2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);
	}
}