Question

I'm trying to open a fifo pipe, into which one thread writes, the synchronization is all good. However, for understandable reasons I need it to be opened in append mode.

When I open it as follow:

        ret_val = mkfifo(lpipename.c_str(), 0666);
        if((pipehandler = open(lpipename.c_str(), O_RDWR)) < 1) 
    {
        perror("Failed to open pipe file");
        syslog(LOG_ERR, "Failed to open pipe file");
        exit(1);
    }

I don't have any problems and I can see the pipe marked in yellow when 'ls'-ing my folder

But when I try to open the pipe as follows, in append mode:

    ret_val = mkfifo(lpipename.c_str(), 0666);
    if((pipehandler = open(lpipename.c_str(), O_RDWR| O_APPEND)) < 1) 
    {
        perror("Failed to open pipe file");
        syslog(LOG_ERR, "Failed to open pipe file");
        exit(1);
    }

I can't see the pipe in folder at all. For the record, I get an error in NEITHER one of the options Does anyone have any idea of why?

Thanks

Was it helpful?

Solution

O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

It may be due to this,for more details look into the below link

http://www.kernel.org/doc/man-pages/online/pages/man2/open.2.html

OTHER TIPS

It's a FIFO. How could it do anything else but append? I believe appending is the norm, thus it will always append no matter how you open it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top