misson20000 / twili

Homebrew debug monitor for the Nintendo Switch.
GNU General Public License v3.0
184 stars 23 forks source link

Linux: Twibd doesn't release socket properly on unclean exit (such as USB permission error) #96

Closed baconwaifu closed 4 years ago

baconwaifu commented 4 years ago

A fix would be passing SO_REUSEADDR to the setsockopt() call, so that it doesn't have to be explicitly released. Linux doesn't allow more than one listening process to bind() to a socket file anyways, so it should be perfectly safe.

One windows, this is the default behavior, and SO_REUSEADDR does something different; I don't think any problems would be caused by this change though.

EDIT: ignore this, the damned socket API is rather poorly documented; AF_UNIX sockets don't even have SO_REUSEADDR. The only way to re-use a socket is to delete the file; so it actually does need the full write permission into /var/run/.

misson20000 commented 4 years ago

Yeah, sorry. I'm not pleased about it either. That's a big reason why I have systemd integration.