Im writing a daemon in C that posts data to PostgreSQL database using libpq library. It has structure like this:
init(...) // init function, opens connection
while(1){export(...)} // sends commands
When someone kills the application, it leaves open connection on PostgreSQL server. I want to avoid that. Opening and closing connection in export(...) function is not an option, because this code is part of performance dependent framework.