Контрольная работа: Копирование содержимого Файла 1 в остальные файлы
signal(SIGUSR2, p41);
printf("***SIGUSR2*** prss 1 (%d) has got a signal from prss 4 (%d)\n",pid1,pid1+2);
fd = open("file1", O_RDONLY);
read(fd,temp_buf1,strlen(temp_buf1));
close(fd);
creat("temp_file",fd);
printf("* *SIGUSR2* * : temp_file was created\n");
fd = open("temp_file", O_WRONLY);
write(fd,temp_buf1,strlen(temp_buf1));
close(fd);
printf("***SIGUSR2*** : end\n");
}
4 ТЕСТИРОВАНИЕ
Результат выполнения программы в консоли:
yuna@YunieHost:/media/8_Gb_hard_ONPU/LINUX/rgr 28march$ ./rgr
--- func creat_mem(): memory creating: 32bytes --- pid=6798
--- func creat_sem(): semaphor creating: --- pid=6798
=II= prss2, pid = 6799, parent: 6798
=I= prss1, pid = 6798, parent: 6655
=III= prss3, pid = 6801, parent: 6799
=IV= prss4, pid = 6800, parent: 6798
I: reading from FILE1: << RGR sPO by yuna 18.05.2008 >>
***SIGUSR2*** prss 1 (6798) has got a signal from prss 4 (6800)
* *SIGUSR2* * : temp_file was created
***SIGUSR2*** : end
================== prss1: writing to memory
================== prss2: file2 editing /Semaphor/
II: writing to FILE2: << RGR sPO by yuna 18.05.2008 >>
--- func creat_mesg(): message creating: --- pid=6799
=II= __eto konec prssa2