Hacker News new | ask | show | jobs
by rramadass 1437 days ago
>They would write the file descriptors of connected sockets to a file, restart the process, then read the list of file descriptors back into memory and resume normal use of the socket

Nope. When a Process exits for whatever reason, the OS closes and releases all resources connected with all File/Socket descriptors for that Process.

You will have to architect your System to explicitly accommodate this scenario. Some techniques here : https://stackoverflow.com/questions/55006657/can-i-allow-my-...

2 comments

Not quite. Terminating a process releases its filehandles, and if any sockets are now unreferenced, they are closed. But if there is a live filehandle in another process, the socket stays alive.

You can send socket file handles over UNIX domain sockets, so you could use this to export your list of sockets to persist over restart.

Yep (reference counting in play), It is already mentioned in the SO answer i linked to.
Ah, yeah, "restart the process" was not the right description of what was happening in the cases I was thinking of - they'd exec themselves to hot reload code which I see is the first suggestion on the SA answer you linked.