Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <signal.h>
- void myfunc(int signum){
- printf("in handler\n");
- exit(0);
- }
- void main()
- {
- pid_t pid;
- int n;
- if((pid = fork()) == 0){
- signal(SIGUSR1, myfunc);
- pause();
- printf("child pid is %d and parent is %d\n", getpid(), getppid());
- }
- else{
- printf("parent pid is %d\n", getpid());
- printf("child pid is %d\n", pid);
- kill(pid, SIGUSR1);
- wait(NULL);
- }
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement