On Tue, May 10, 2005 at 05:31:56PM -0400, Christopher Murtagh wrote: > > I'm not sure what happens when you do "exit" here, but I'll lay odds > > against it being exactly the right things. > > It ends the daemonized process, kinda like a wrapper suicide. :-) I think you have a problem here. PostgreSQL is a complete program, which use signal, atexit handlers, callback all or which fork() preserves. When your "little daemon" exits it may trigger all the code normally run on backend exit, you know, closing WAL files, etc... The rest of the program has no idea it's a forked process rather than a real one. Say the backend had a alarm() set and it goes off in your forked process. Havoc ensues... > From my (somewhat limited experience) point of view, I think that this > plperlu script isn't much different from writing a daemon to receive > signals via NOTIFY. Instead the script is self daemonizing, and it will > always run (instead of a couple of NOTIFY's building up and only one > being sent), which is more in line with what I want. Except that the daemon will be a client process that uses the database to do work whereas with the other you're duplicating the server without telling it and putting your data at risk... > Sorry, my explanation probably isn't very clear at all, I've been > writing talk material and my brain is in a totally different space. Feel > free to deliver any LARTs. :-) You should never fork() and not exec() a large program unless it knows you're doing it. Note that exec() doesn't run atexit handlers but exit() does. Big difference... Hope this helps, -- Martijn van Oosterhout <kleptog@xxxxxxxxx> http://svana.org/kleptog/ > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a > tool for doing 5% of the work and then sitting around waiting for someone > else to do the other 95% so you can sue them.
Attachment:
pgpIOqc5asWkN.pgp
Description: PGP signature