I have processes that after started, bind to an address and port. These processes are run in screen using exec
so that the screen closes when the child process closes.
When killing the process, I use kill -9 PID
, but sometimes the screen ends, yet when I restart the process, the old process is still using the port, and I have to terminate the process again.
I've also read that SIGKILL
leaves sockets open, stale memory, random resources in use, so I turned to just plain kill PID
, which is a SIGTERM
.
Is a SIGTERM
guaranteed to allow the process to unbind from the address and port, or is there a better alternative?