Don't crash when there is a leftover socket file
When there is a socket file in the current directly and no server is running, 'hdevtools check' fails with:
hdevtools: bind: resource busy (Address already in use)
I'll have to think about this...
Can you please explain under what circumstances you end up with the leftover socket file? It should usually be automatically deleted when the hdevtools server exits.
It mainly happens when I have to kill a hdevtools process with SIGKILL.
The proper way to stop the hdevtools process is to run hdevtools --stop-server
This should make sure that the socket file is cleaned up.
Yes, I know that. However when the machine is running out of memory hdevtools --stop-server is often too slow.
Also I believe that the socket file will be left on hard reset of the computer, for example.
I can't say I've been bitten by this, but I think it's best to remove stale socket files because hdevtools could require a kill -9, or it might get killed by something else beyond user control, etc.
I found this pull request when I encountered the same problem. I do not know how I ended up with the stale socket file, but there it was, so I had to solve the problem some way.
Perhaps the program could at least exit with a more descriptive message about the stale socket file. If the message included the path to the file, it would be completely obvious what the user needs to do to fix the problem.
I ended up with a leftover .hdevtools.sock file that caused the same error. It may have been caused by a hard-reset. It manifested as vim-hdevtools silently failing to check for errors, which took a bit to track down.
I'd love to see this merged in.
I encountered this when running hdevtools inside a Docker container with host volumes mounted into the container. When the container is removed the stale socket remains on the host system.
I am constantly removing this socket file to re-check after making changes to included libraries so I don't see the harm in automating it (at least in certain circumstances).
I'll have to merge this into my branch, @bitc isn't active in this repo as far as I know.
I've merged this request into my fork and pushed it up to hackage.