Загрузка данных


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

int main() {
    int fd;
    size_t size;

    // Создаём FIFO (если уже существует — не страшно)
    mkfifo("myfifo", 0666);

    fd = open("myfifo", O_WRONLY);
    if (fd < 0) {
        printf("Can't open FIFO for writing\n");
        exit(1);
    }

    size = write(fd, "Hello, world!", 14);
    if (size != 14) {
        printf("Can't write all string\n");
        exit(1);
    }

    close(fd);
    return 0;
}



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

int main() {
    int fd;
    ssize_t size;
    char buffer[100];

    fd = open("myfifo", O_RDONLY);
    if (fd < 0) {
        printf("Can't open FIFO for reading\n");
        exit(1);
    }

    size = read(fd, buffer, sizeof(buffer) - 1);
    if (size < 0) {
        printf("Can't read string\n");
        exit(1);
    }

    buffer[size] = '\0';
    printf("Received: %s\n", buffer);

    close(fd);
    return 0;
}