/* kill1.c++ signal from child to parent */ #include using namespace std; #include #include #include #include #include int main() { // kill1.c++ int cPID, status ; cPID = fork(); if(cPID == -1){ perror("fork() failed\n"); exit(1); } if(cPID > 0) { while(1){ cout << "Parent running...\n"; sleep(1); } waitpid(cPID, &status, 0) ; } else { // child int pPID = getppid(); sleep(5); kill(pPID, SIGTSTP); cout << "SIGTSTP sent to parent\n"; sleep(5); cout << "SIGCONT sent to parent\n"; kill(pPID, SIGCONT); sleep(5); cout << "SIGINT sent to parent\n"; kill(pPID, SIGINT); } return 0 ; }