FIFO Writer

PHOTO EMBED

Thu Jun 06 2024 00:52:03 GMT+0000 (Coordinated Universal Time)

Saved by @login

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

#define FIFO_PATH "/tmp/myfifo"

int main() {
    int fd;
    char *message = "Hello from writer process!";
    
    // Open the FIFO for writing
    fd = open(FIFO_PATH, O_WRONLY);
    if (fd == -1) {
        perror("open");
        exit(EXIT_FAILURE);
    }

    // Write to the FIFO
    write(fd, message, strlen(message) + 1);

    // Close the FIFO
    close(fd);

    return 0;
}
content_copyCOPY