Контрольная работа: Циклический обмен содержимым файлов
{
char *a4 = "4", *a3 = "3", *a2 = "2", *a1 = "1";
int p1, p2, p3, p4;
printf ("Cozdanie vseh processov:\n");
printf ("\n");
printf ("Cozdanie processa 4 \n");
printf ("Porozhdenie processa 1 processom 4\n");
printf ("Porozhdenie processa 2 processom 1\n");
printf ("Porozhdenie processa 3 processom 2\n");
p4 = fork();
if(p4)
{
p1 = fork();
exit(0);
}
if(p1)
{
file_obmen(a4, a3);
printf("Write file 4 >>> file 3\n");
p2 = fork();
}
sleep(1);
if(p2)
{
file_obmen(a3, a2);
printf("Write file 3 >>> file 2\n");
p3 = fork();
exit(0);
}