Skip to content
Advertisement

Programming in Linux – FIFO

I have created fifo, try to write to it: echo "text" > myfifo and read it with my programm. But when I write to fifo nothing shows.

I have tried many options, turning off and on NON_BLOCK mode and so on but nothing seems to help.

JavaScript

Advertisement

Answer

This

JavaScript

needs to be

JavaScript

(there’s probably no need for the O_NONBLOCK flag, but your most grievous error is that you’re assigning a boolean result (0 or 1; not the file descriptor) to tab[i] )

Last but not least, for

JavaScript

to work, you need to put a null character after the last character you read:

JavaScript

(Also you need to make sure there’s always space for the terminating null: either ask for 9 characters or allocate 11 for the array).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement