1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #define P_MAX 10 int main(){ int pid[P_MAX];
for( i=0 ; i < P_MAX && (pid[i] = fork()) > 0 ; i++ );
if( i == P_MAX ){ for( i = 0 ; i < P_MAX ; i++ ){ wait(&val); } }else if( pid[i] == 0){ printf("child:%d\n",i); exit(0); }else{ perror("child process") ; exit(0); } return 0; }
|