The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Aaaa
By Guest on 26th February 2025 06:24:11 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 = fork();
  10. if (pid == 0) {
  11. pid_t pid1 = fork();
  12. pid_t pid2 = fork();
  13. if(pid1 == 0 || pid2 == 0) {
  14. printf("\nSono il processo: %d,figlio di %d \n", getpid(), getppid());
  15. return 0;
  16. }
  17. else {
  18. printf("\nSono il processo: %d,figlio di %d, padre di %d e %d \n", getpid(),
  19. getppid(), pid1, pid2);
  20. sleep(2);
  21. }
  22. return 0;
  23. }
  24. else { //padre
  25. printf("\nSono il processo %d., padre di %d \n", getpid(), pid);
  26. sleep(3);
  27. return 0;
  28. }
  29. }



  • Recent Pastes

Upload your own Photos at PasteNet Photos


Free Packet LLC
For all your hosting needs!