Catching server shutdown in C
Hiya
I am writing a daemon in C which monitors a table stored in postgres.
I would ideally like the daemon to be able to withstand things such as
the db connection going away or the db being shutdown, and simply keep
trying to connect rather than just fall on it's face.
Is there a way that I can catch a server shutdown/connection loss
cleanly? I did a quick search of the mailling list but didn't see
anything.
Thanks for your help
--
-----
Graeme Hinchliffe (BSc)
Core Internet Systems Designer
Zen Internet (http://www.zen.co.uk/)
Direct: 0845 058 9074
Main : 0845 058 9000
Fax : 0845 058 9005
On Mon, Aug 23, 2004 at 09:53:43AM +0100, Graeme Hinchliffe wrote:
Hiya
I am writing a daemon in C which monitors a table stored in postgres.
I would ideally like the daemon to be able to withstand things such as
the db connection going away or the db being shutdown, and simply keep
trying to connect rather than just fall on it's face.Is there a way that I can catch a server shutdown/connection loss
cleanly? I did a quick search of the mailling list but didn't see
anything.
Normally when the database exits, clients receive an error on the next
transaction usually. I create a wrapper for query executations which,
when noticing the database has gone, tries to reopen the connection. It
returns unknown if it fails. Not exactly compatable with transactions
though...
Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Show quoted text
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.