I am writing a program for POSIX (OSX) where I will have many processes sending messages to one listener, who is essentially a logging thread. All of the processes are running in seperate programs, and using a single named pipe (FIFO) that many processes write to, but only a single process reads from is very tempting.
Questions:
1) Will this work? - I can make this work using bash to setup a fifo with multiple processes writing to it, so I know in theory this works. But in practice, are there issues I'm glossing over?
shell #1
$ mkfifo /tmp/fifo
$ cat /tmp/fifo
shells #2 and #3
$ cat > /tmp/fifo
"Type stuff here, after hitting enter, it is read by shell #1"
2) If each writer only writes relatively short messages (< 100 bytes?) then can I assume that each call to write() will will be sent to reader in it's entirety? Or will half of one message be at risk of garbled with half of another message from a different writer?
thanks for any advice.