[comp.unix.questions] how to make fifos keep data?

koerberm@nixsin.UUCP (Mathias Koerber) (05/31/90)

Hello netlanders,

I have a somewhat urgent problem on my hands, so could you please help me?

I need to know if there is a possibilty to make named pipes (fifos) on
Unix SysV keep their data, even when the reading process dies or the machine
crashes. What I think of is someting like buffering on disk. I observed that
the writing process may as well,die, no data is lost. But even if there is
more data available, a crash of the reading process deleted all the data that
has already been written to the pipe. I have to use the pipes to transfer data
from a unix-device-handler into PROGRESS 4GL/RDBMS online so that the database
can be updated immediately. I cannot do anything on the reading side, but
the writing side might be able to set some parameters etc.

If anyone knows how to accomplish this, please let me know, I would be very
grateful.

My configuration:	Nixdorf Targon /31 M15	TOS4.0.11

Thx,	Mathias
-- 
Mathias Koerber           |Tel:   +65 / 7473828 ext 1852|Fax: +65 / 7474331
Nixdorf Computer Singapore|EUnet: koerber.sin@nixpbe    |nerv:  koerber.sin
2 Kallang Sector          |uunet: uunet!linus!nixbur!koerber.sin
Singapore 1334            |[Standard-disclaimer:All views personal...     ]

martin@mwtech.UUCP (Martin Weitzel) (06/05/90)

In article <1038@nixsin.UUCP> koerberm@nixsin.UUCP (Mathias Koerber) writes:
>Hello netlanders,
>
>I have a somewhat urgent problem on my hands, so could you please help me?
>
>I need to know if there is a possibilty to make named pipes (fifos) on
>Unix SysV keep their data, even when the reading process dies
                                          ^^^^^^^^^^^^^^^^^^^^ (first) 
>or the machine crashes.
        ^^^^^^^^^^^^^^^ (second)

The first is easy: Let some dummy process open the FIFO for read and write
and then sleep forever. The following C-program will do that, when given
the name of the FIFO as argument (you may want to add some error messages).

main(argc, argv) int argc; char **argv;
{
	if (argc > 1 && open(argv[1], 2) != -1) pause();
}

The second is rather impossible if you want to stay with FIFO-s -
at least if you want to protect against any kind of crash (eg. someone
hits the "RESET" of "BOOT" switch). If only "more or less controlled
rapid shutdowns" are your concern, you might extend the above daemon
so that it catches the respective signal (which is sent before the
machine goes down), sucks everything off the FIFO and writes to a
file. When restarted later, it should look for that emergency stop
file and re-feed to the FIFO.

-- 
Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83