int main()
{
int i;
if (fork() == 0)
{
for (i = 1; i < 3; i++)
printf("This is child process"n");
}
else
{
for (i = 1; i < 3; i++)
printf("This is parent process"n");
}
}
执行结果为:
This is child process
This is child process
This is parent process
This is parent process