The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Magnaitoo
By Guest on 26th February 2025 05:27:42 AM | Syntax: TEXT | Views: 1



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <sys/wait.h>
  4. #include <fcntl.h>
  5. #include <stdio.h>
  6. #include <unistd.h>
  7. #include <stdlib.h>
  8. int main() {
  9. pid_t pid;
  10. pid = fork(); //qui viene eseguita la generazione del nuovo processo
  11. if (pid == 0) {
  12. printf("Sono il processo figlio: %d. ", getpid()); //getpid() restituisce il pid
  13. printf("\n\nPremi un tasto per uscire");
  14. char c;
  15. scanf("%c",&c); // trucco per bloccare il processo
  16. return 0;
  17. } else {
  18. printf("Sono il processo padre: %d. ", getpid());
  19. printf("\n\nPremi un tasto per uscire");
  20. char c;
  21. scanf("%c",&c); // trucco per bloccare il processo
  22. return 0;
  23. }
  24. }



  • Recent Pastes

Upload your own Photos at PasteNet Photos


Free Packet LLC
For all your hosting needs!