Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <signal.h>
- #include <stdio.h>
- #include <wait.h>
- int counter = 0;
- int pid;
- void handler (int sig) {
- /* counter++;
- printf ("pid do handler= %d, counter= %d \n", getpid(), counter);
- sleep(1);*/
- return;
- }
- int main() {
- int i;
- int status;
- signal(SIGUSR2, handler);
- if (fork()==0){
- for (i=0;i<5;i++) {
- kill (getppid(), SIGUSR2);
- printf("sent SIGUSR2 to parent\n");
- WSTOPSIG(1);
- sleep (2);
- }
- exit(0);
- }
- /*while ((pid = waitpid(-1, &status, 0) ) > 0 ) {
- if (..............................) printf("pai esperou por filho %d parado pelo sinal %d\n",
- pid, ..........................................);
- ......................................);
- }*/
- // exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement