Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.unix.questions Subject: Re: how to make fifos keep data? Keywords: fifos pipes crash Message-ID: <778@mwtech.UUCP> Date: 5 Jun 90 09:55:31 GMT References: <1038@nixsin.UUCP> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 31 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