Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice04 / ex1.c
blob: da92ec617811cab8a9a53ec41711db20d17018fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h> // printf, perror
#include <unistd.h> // getpid, getppid, execlp
#include <sys/types.h> // pid_t
int main(int argc, char* argv[]) {
	pid_t pid = getpid();
	pid_t parent = getppid();
	printf("%d %d\n", pid, parent);
	if (execlp("ps", "ps", (char*)NULL) < 0) {
		perror("execlp");
		return 1;
	}
}