LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   FIFO question (https://www.linuxquestions.org/questions/linux-newbie-8/fifo-question-47634/)

gauge73 02-28-2003 03:07 PM

FIFO question
 
I am running a dedicated Neverwinter Nights server running on my RH8.0 Linux box. If you run this service with the correct options you can type commands into the server to load modules and broadcast server messages and such. What I want to do (simply for learning's sake) is to have my backup script on my server tell the NWN process to broadcast a message warning of lag caused by the backup.

I asked on a NWN Server Admin forum how to go about this and I was told to look into FIFOs. I did some peeking around on what they are. I was unable to get a firm grasp on how to have a service read a FIFO. The only command that I've found that is related to this is mkfifo, which seems quite simple.

Could anyone walk me through making a service take it's input from a FIFO instead of from standard input, how to make a script write to a FIFO, and anything else that's relevant to the issue?

Dark_Helmet 02-28-2003 11:39 PM

Official disclaimer: I have never used FIFOs, so please don't take what I suggest as gospel, truth, or anything remotely resembling an authoratative response.

I read the man page for mkfifo and it didn't say much other than "use this command to make a fifo"... duh. So I tried:
Code:

apropos FIFO
and got a listing of other commands. Most are C-oriented, but the one you might want to take a look at is:
Code:

man 4 fifo
It says FIFOs are pipes maintained by the kernel that have entries in the filesystem as a "reference point". That's what I love about linux: everything, EVERYTHING, is a file. That means you should be able to access the pipe just like you would access any regular file. Meaning, to write to the FIFO, you probably only have to issue a command like so:
Code:

echo "Server may experience lag from backup process" > /path/to/fifo
Reading from it should be fairly simple as well.

I don't know if it will be an issue for you, but you should have a process trying to read the FIFO before a different process writes to it. The kernel has nowhere to send the write data if nobody is ready to read it.

If this doesn't get you started, and nobody else jumps in, you may be better served asking a similar question in a programming forum. FIFOs are a classic programming language structure. You may get a lot of technical details and a lot of it will probably be geared toward implementing a FIFO in C, but you should be able to get what you need.


All times are GMT -5. The time now is 10:14 PM.