>> Included is a example program appears in our docs (libpq.sgml).
If you're going to do any work on that example, how about transforming
it into something useful, ie, a more realistic example of using NOTIFY.
It should be using a select() to wait for input, not a sleep() loop.
As for the cleanup code, leave it in place, and make the sample program
break out of its loop when a specific NOTIFY name is received.
regards, tom lane