I have a linux application written in c++. The application listens to a socket on a certain port. I implemented this using ACE Acceptor. In addition the application starts postgresql database using the init script /etc/init.d/postgresql start by calling the ACE_OS::system function.
The problem I am having is: When the application exits, the port is still occupied. When I run netstat I see that the postgres is listening to that port. (This only happens if I start postgres from the application on any given port).
Is there a way to close the port? Why does postgres listen to that port?