zolrath / wemux

Multi-User Tmux Made Easy
MIT License
3.63k stars 139 forks source link

Modify kill host command to forcibly remove socket #65

Open jamesb opened 7 years ago

jamesb commented 7 years ago

In a configuration where multiple users can host wemux, suppose user foo starts a wemux session and then ends the tmux session without using wemux stop (say, by closing all tmux windows). In this scenario, the wemux socket will be left as something like... srw-rw-rw- 1 foo foo 0 Sep 6 10:55 wemux-wemux= ... and another user, baz, won't be able to successfully run wemux start because the server isn't running and foo owns the socket. If baz has sudo access, baz can sudo chown baz /tmp/wemux/wemux and then remove it.

The wemux script currently responds to both wemux stop and wemux kill by calling the stop_server function. In this PR, we differentiate wemux kill by attempting to forcibly change the ownership of the socket (using sudo, as above) before calling stop_server. This is convenient in a multi-tenant compute instance and should help ease some frustration when colleagues forget to cleanly stop the wemux session.