How to delete unix socket entries

Paul Robinson paul at iconoplex.co.uk
Tue Jun 24 10:14:15 PDT 2003


On Tue, Jun 24, 2003 at 08:59:49PM +0400, Varshavchick Alexander wrote:

> I had a wrong-behaved server application which opened a unix socket to
> respond to incoming connections, so that after the socket was opened, the
> application core dumped each time it was launched. As a result, 'netstat
> -f unix' now shows a lot of not-needed active entries. Is there any way to
> delete them, or will they eventually die by themselves?

A "better" way to do this is to use sockstat:

paul at hannibal:~> sockstat -u
USER     COMMAND    PID   FD PROTO  ADDRESS
root     screen   30084    4 stream /tmp/screens/S-paul/30084.ttyp0.hannibal
root     pure-ftp 22112    3 dgram  syslogd[67]:3
root     named    56824    3 dgram  syslogd[67]:3
root     ntpd     11575    3 dgram  syslogd[67]:3
mysql    mysqld   53779    6 stream /tmp/mysql.sock
root     syslogd     67    3 dgram  /var/run/log

paul at hannibal:~>

you then *know* which are the safe sockets to destroy. If it's a stream 
socket, you've got a file that you can rm - they're not going anywhere of 
their own accord.*

The short answer then is "rm them, but make sure you rm the right ones".

-- 
Paul Robinson

* If you reboot the machine, depending on how things are setup on your 
machine, /tmp and /var/tmp may or may not get rm'ed anyway, so the system 
has "cleared" the sockets on your behalf.


More information about the freebsd-hackers mailing list