Loading...
Другие языки | Cи процесс
Всем привет, вот есть такая задачка
"Процесс 1 порождает потомка 2. П2 непрерывно передает П1 ряд натуральных чисел С "
Вот код

#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
pid_t pid;
int fd[2];
int result = pipe(fd);

if(result < 0){
perror("pipe");
exit(1);
}

pid = fork();

if(pid < 0){

perror("fork");
exit(2);

} else if(pid == 0){ /* код потомка */

int message = 0;
for(; message < 100000; message++){

write(fd[1], &message, sizeof(int));

}
close(fd[1]);
exit(0);

} else {
int message, counter = 0;

while(true){

read(fd[0], &message, sizeof(int));
printf("message: %dn", message);
counter++;
if(counter == 9){
counter = 0;
sleep(1);
}

}

}

return 0;
}


Вот такая ошибка error: ‘true’ undeclared (first use in this function)
while(true){
________
посл. ред. 07.06.2017 в 18:33; всего 1 раз(а); by wladua2016
Онлайн: 1
Время:
Gen. 0.0487
(c) ByMAS.RU 2010-2025