Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <errno.h>
- #include <unistd.h>
- int main()
- {
- pid_t pid;
- int count = 1;
- printf( "Moj pid to: %d\n", getpid() );
- printf( "Bede tworzyc procesy potomne \n" );
- switch( pid = fork() )
- {
- case -1:
- {
- printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
- }
- case 0:
- {
- printf("Tworze proces potomny nr %d\n", count);
- count++;
- switch( pid = fork() )
- {
- case -1:
- {
- printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
- }
- case 0:
- {
- printf("Tworze proces potomny nr %d\n", count);
- count++;
- switch( pid = fork() )
- {
- case -1:
- {
- printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
- }
- case 0:
- {
- printf("Tworze proces potomny nr %d\n", count);
- count++;
- switch( pid = fork() )
- {
- case -1:
- {
- printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
- }
- case 0:
- {
- printf("Tworze proces potomny nr %d\n", count);
- count++;
- switch( pid = fork() )
- {
- case -1:
- {
- printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
- }
- case 0:
- {
- printf("Tworze proces potomny nr %d\n", count);
- count++;
- switch( pid = fork() )
- {
- case -1:
- {
- printf( "Error w f. fork() : %d %s\n", errno, strerror( errno ) );
- }
- case 0:
- {
- return 0;
- }
- default:
- {
- }
- }
- if(wait(0) == -1)
- puts("Blad");
- return 0;
- }
- default:
- {
- }
- }
- if(wait(0) == -1)
- puts("Blad");
- return 0;
- }
- default:
- {
- }
- }
- if(wait(0) == -1)
- puts("Blad");
- return 0;
- }
- default:
- {
- }
- }
- if(wait(0) == -1)
- puts("Blad");
- return 0;
- }
- default:
- {
- }
- }
- if(wait(0) == -1)
- puts("Blad");
- return 0;
- }
- default:
- {
- }
- }
- if(wait(0) == -1)
- puts("Blad");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment