title: Why aren't UNIX domain sockets removed automatically when no longer referenced?
body: <p>When a process binds a name to a TCP socket (i.e. ip:port pair) and exits, it doesn't has to explicitly cleanup anything: another process can reuse the same ip:port. Same with the abstract UNIX sockets on Linux (when <code>sun_path</code> starts with zero byte). However, when using traditional UNIX sockets, one has to <code>unlink</code> it after it is no longer needed (or before <code>bind</code>-ing, which is not very good since you can remove something important).</p>
  
  <p>According to my observations, once the last file descriptor referring to the UNIX socket is closed, the socket file is useless garbage: <code>open</code> returns <code>ENODEV</code>, <code>connect</code> returns <code>ECONNREFUSED</code>, and <code>bind</code> returns <code>EADDRINUSE</code>. The only thing one can (and has to) do is <code>unlink</code>.</p>
  
  <p>Shouldn't OS remove socket file from file system automatically when it's no longer used?</p>