#include <stdio.h>
int main(void)
{
int pid;
pid=fork();
if(pid==0)
{
int j;
for(j=0;j<10;j++)
{
printf("child:=%d\n",j);
sleep(1);
}
exit(0);
}
else if(pid>0)
{
int i;
for(i=0;i<10;i++)
{
printf("parent:%d\n",i);
sleep(1);
}
}
else
{
fprintf(stderr,"couldn't fork");
exit(1);
}
}
No comments:
Post a Comment