Preface (skip for the real problem): I have an application that is listening to port 843. This process is run as root. Sometimes killing the process (with ^C) leaves it hanging for a long time (forever?). Being impatient, I kill it with
kill -9. The problem now is that port 843 is still listening, even though there no application there.
lsof -i shows me no processes listening to 843, even when run as root. Looking at
netstat -a, however, shows that it is listening, and even some connections that weren't torn down correctly:
Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp6 0 0 localhost.843 localhost.60927 CLOSE_WAIT tcp6 386 0 localhost.843 localhost.60926 CLOSE_WAIT tcp6 0 0 localhost.843 localhost.60925 CLOSE_WAIT tcp6 386 0 localhost.843 localhost.60924 CLOSE_WAIT tcp46 0 0 *.843 *.* LISTEN tcp4 0 0 *.843 *.* LISTEN
A similar question recommends that I don't get into this situation in the first place. That's sound advice, but a bit hard since it's not my application. Furthermore, it would be nice to be get out of it regardless.
Any way I can get out of this mess without rebooting? Is the fact that I ran it as root important? (I only need root to listen to low-numbered ports, for which I didn't find a way without installing software like authbind).