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; }