pborawski

na wejsciowke

Oct 22nd, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.81 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <sys/types.h>
  5. #include <sys/wait.h>
  6. #include <errno.h>
  7. #include <unistd.h>
  8.  
  9. int main()
  10. {
  11.     pid_t pid;
  12.     int count = 1;
  13.     printf( "Moj pid to: %d\n", getpid() );
  14.     printf( "Bede tworzyc procesy potomne \n" );
  15.     switch( pid = fork() )
  16.     {
  17.             case -1:
  18.             {
  19.                 printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
  20.             }
  21.             case 0:
  22.             {
  23.                 printf("Tworze proces potomny nr %d\n", count);
  24.                 count++;
  25.                 switch( pid = fork() )
  26.                 {
  27.                         case -1:
  28.                         {
  29.                             printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
  30.                         }
  31.                         case 0:
  32.                         {
  33.                             printf("Tworze proces potomny nr %d\n", count);
  34.                             count++;
  35.                             switch( pid = fork() )
  36.                             {
  37.                                     case -1:
  38.                                     {
  39.                                         printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
  40.                                     }
  41.                                     case 0:
  42.                                     {
  43.                                         printf("Tworze proces potomny nr %d\n", count);
  44.                                         count++;
  45.                                         switch( pid = fork() )
  46.                                         {
  47.                                                 case -1:
  48.                                                 {
  49.                                                     printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
  50.                                                 }
  51.                                                 case 0:
  52.                                                 {
  53.                                                     printf("Tworze proces potomny nr %d\n", count);
  54.                                                     count++;
  55.                                                     switch( pid = fork() )
  56.                                                     {
  57.                                                             case -1:
  58.                                                             {
  59.                                                                 printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
  60.                                                             }
  61.                                                             case 0:
  62.                                                             {
  63.                                                                 printf("Tworze proces potomny nr %d\n", count);
  64.                                                                 count++;
  65.                                                                 switch( pid = fork() )
  66.                                                                 {
  67.                                                                         case -1:
  68.                                                                         {
  69.                                                                             printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
  70.                                                                         }
  71.                                                                         case 0:
  72.                                                                         {
  73.                                                                             return 0;
  74.                                                                         }
  75.                                                                         default:
  76.                                                                         {
  77.                                                                            
  78.                                                                         }
  79.                                                                 }
  80.                                                                 if(wait(0) == -1)
  81.                                                                     puts("Blad");
  82.                                                             return 0;
  83.                                                             }
  84.                                                             default:
  85.                                                             {
  86.                                                                
  87.                                                             }
  88.                                                     }
  89.                                                     if(wait(0) == -1)
  90.                                                         puts("Blad");
  91.                                                 return 0;
  92.                                                 }
  93.                                                 default:
  94.                                                 {
  95.                                                    
  96.                                                 }
  97.                                         }
  98.                                         if(wait(0) == -1)
  99.                                             puts("Blad");
  100.                                     return 0;
  101.                                     }
  102.                                     default:
  103.                                     {
  104.                                        
  105.                                     }
  106.                             }
  107.                             if(wait(0) == -1)
  108.                                 puts("Blad");
  109.                         return 0;
  110.                         }
  111.                         default:
  112.                         {
  113.                            
  114.                         }
  115.                 }
  116.                 if(wait(0) == -1)
  117.                     puts("Blad");
  118.             return 0;
  119.             }
  120.             default:
  121.             {
  122.                
  123.             }
  124.     }
  125.     if(wait(0) == -1)
  126.         puts("Blad");
  127.     return 0;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment