Generally speaking, not as good design practice, when you kill a program, kernel takes care of its open sockets for the now dead process too.
That does not mean that all transactions are completed gracefully, etc. It simply means that the socket is closed. As long as it doesn't depend on something else to keep it open, such as SMB or stateless versions of NFS, etc. -T On Dec 2, 2017 2:46 AM, "Russell Senior" <[email protected]> wrote: > e.g. http://www.thegeekstuff.com/2012/03/catch-signals-sample-c-code/ > > On Sat, Dec 2, 2017 at 2:44 AM, Russell Senior > <[email protected]> wrote: > > Generally, if you need to do cleanup at exit, you register a signal > > handler to handle the right signal, and have the signal handler > > explicitly do the things you want (in this case, closing the sockets). > > > > On Fri, Dec 1, 2017 at 11:18 PM, michael <[email protected]> > wrote: > >> If kill is used to stop a C program running on Linux that has open > sockets, > >> the sockets get orphaned. > >> > >> How can I in the event of a ctrl-c close all sockets owned by the > program > >> immediately? Waiting 3-10 seconds for > >> Linux to close the orphaned sockets is too long. > >> _______________________________________________ > >> PLUG mailing list > >> [email protected] > >> http://lists.pdxlinux.org/mailman/listinfo/plug > _______________________________________________ > PLUG mailing list > [email protected] > http://lists.pdxlinux.org/mailman/listinfo/plug > _______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
