Monday, February 5, 2024

[SOLVED] Would the service socket be closed before core dump or after it?

Issue

If a service crashes and generates a core dump, will the socket which the service listens be closed immediately or closed when the core dump is done?

id='dv3'>

Solution

What I see in my application is that a listening socket is not closed when a signal arrives and Linux starts writing a core file. It is only closed when the core file has been written.

In order to change this behavior it is possible to close a listening socket right in a signal handler. close() is async-signal-safe: http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html



Answered By - user184968
Answer Checked By - Robin (WPSolving Admin)