Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice05 / ex6.c
blob: 7e0376d43481961742ef36f780afced56f83fd91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <unistd.h> // execvp, fork
#include <stdio.h> // printf
#include <sys/wait.h> // wait

int main(int argc, char* argv[]) {
	pid_t fpid = fork();
	if (fpid == 0) {
		execvp(argv[1], argv + 1);
	}
	else {
		int status;
		wait(&status);
		printf("%d %d\n", fpid, status);
	}
}