Unlink any existing socket before binding
This commit is contained in:
parent
6195451899
commit
d0ec200a27
|
@ -128,6 +128,7 @@ int setup_socket(const char* name, int perms)
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strcpy(addr.sun_path, name); // main() ensures it is less than UNIX_PATH_MAX bytes
|
strcpy(addr.sun_path, name); // main() ensures it is less than UNIX_PATH_MAX bytes
|
||||||
|
|
||||||
|
unlink(name); // unlink any existing socket, but ignore errors
|
||||||
if(bind(fd, (struct sockaddr*)&addr, sizeof(addr))) {
|
if(bind(fd, (struct sockaddr*)&addr, sizeof(addr))) {
|
||||||
LOG(LOG_CRIT, "Couldn't bind socket (fd %d) to file ``%s'' - %s (%d).",
|
LOG(LOG_CRIT, "Couldn't bind socket (fd %d) to file ``%s'' - %s (%d).",
|
||||||
fd, name, strerror(errno), errno);
|
fd, name, strerror(errno), errno);
|
||||||
|
|
Loading…
Reference in New Issue