danpalol

settimoesercizio.c

Oct 26th, 2016
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <signal.h>
  5.  
  6. int main (){
  7. pid_t pid;
  8. pid=fork();
  9. if (pid < 0)
  10. {
  11. printf("fork error\n");
  12. exit(1); }
  13. else if (pid==0) {
  14. for(;;) printf("sono il figlio e giro a cazzo\n");
  15. printf("errore nel for\n");
  16. exit(0); }
  17. else { sleep (2);
  18. kill(pid,SIGKILL);
  19. printf("\nho ucciso mio figlio\n");
  20. }
  21. }
Add Comment
Please, Sign In to add comment