You are on page 1of 1

#include

#include
#include
#include
#include

<sys/wait.h>
<sys/types.h>
<unistd.h>
<stdlib.h>
<stdio.h>

int main()
{
int i, status;
int n = 2;
char num[] = "";
char alfa[] = "3433333333333333333333";
for(i=0; i<n; i++)
{
if (fork()==0)
{
num[] = "1,2,3,4,5,6,7,8,9,10";
exit(0);
}
else /* (OPCIONAL) pai terminar apenas aps todos os filhos */
{
waitpid(0,&status,0);
}
}
printf("Pai (ID %d)\n", getpid());
return 0;
}
/*{
int i, status;
int n = 2;
const char *num, *alfa = ""
if (fork()==0)
{
*num = "1,2,3,4,5,6,7,8,9,10"
exit(0);
}
if (fork()==0)
{
*alfa = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X
,Y,Z"
exit(0);
}
else (OPCIONAL) pai terminar apenas aps todos os filhos
{
waitpid(0,&status,0);
}
/*printf(num);
print(alfa);
return 0;
} */

You might also like