Are you writing a library or application? If you are writing a library, you do not have a business installing signal handlers that run counter to the calling application. This is a business application to process such signals, if it wants, and then make the appropriate cleanup calls to your library (outside the context of the signal handler).
Of course, even if you are writing an application, there is no reason to process SIGINT to close sockets and free memory. The only reasons for signal processing: if you do not want to stop working, or if you have unsaved data or a general condition (for example, material in shared memory or the file system) that you need to clear before completion. Freeing memory or closing file descriptors that are used exclusively by your own process are not tasks that you must complete when you exit.
source share