Why not remove UNIX domain socket before bind

Shuxin Yang shuxinyang.oss at gmail.com
Wed Nov 30 16:29:59 UTC 2016

Hi, Maxim:

     Thank you very much ! I think b) is good reason, a) is pretty weak: 
The /the/path/to/unix/domain/socket is a constant string instead of a 
variable; IMHO, it's unlikely to accidentally delete a wrong file due to 



On 11/30/16 6:57 AM, Maxim Dounin wrote:
> Hello!
> On Tue, Nov 29, 2016 at 01:30:25PM -0800, Shuxin Yang wrote:
>>       Is there any reason not to delete UNIX domain socket before bind?
> To name a few, deleting a socket implies that:
> a) any file can be accidentally deleted due to a typo in the
>     listen directive;
> b) attempts to do duplicate listen are not detected and silently
>     break service, e.g., if you start duplicate instance of nginx.
> Instead we delete the socket after closing it.

More information about the nginx-devel mailing list