Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice08 / ex3.c
blob: 6dafe40cabd32547b7e2b312f423197024cdc878 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>

void usr1Handler(int a) {
}

int main() {
	signal(SIGUSR1, &usr1Handler);

	int fp = fork();
	if (fp == 0) { // child
		printf("child\n");
		kill(getppid(), SIGUSR1);
	}
	else {
		pause();
		printf("child finished\n");
	}

	return 0;
}