Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/wait.h>
  3. #include <unistd.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. int main(int argc, char const *argv[])
  9. {
  10.     pid_t pid, pid1;
  11.     int stato;
  12.     pid = fork();
  13.     if(pid == 0)
  14.     {
  15.         pid_t a;
  16.         a = fork();
  17.         if(a == 0)
  18.         {
  19.             while(1)
  20.             {
  21.  
  22.             }
  23.         }
  24.     }
  25.     else
  26.     {
  27.         pid1 = wait(&stato);
  28.         if(WIFEXITED(stato))
  29.             printf("Exit status: %d\n", WEXITSTATUS(stato));
  30.         else if(WIFSIGNALED(stato))
  31.             printf("ANOMALO: %d\n", WTERMSIG(stato) );
  32.     }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement