Hi tech@,

Assume I use netcat with UNIX-domain socket, and there is no
temp_socket. Launch the server:

# ./nc -U -l temp_socket

It works normally. But after netcat exits, launch it again:

# nc -U -l temp_socket
nc: Address already in use

The only method seems to delete temp_socket.

I am not sure this behavior is as expected, and come out following patch
may fix this issue, thanks!

diff --git usr.bin/nc/netcat.c usr.bin/nc/netcat.c
index 341e7e50485..3b2150a01dc 100644
--- usr.bin/nc/netcat.c
+++ usr.bin/nc/netcat.c
@@ -749,6 +749,9 @@ unix_bind(char *path, int flags)
                return -1;
        }

+       if (lflag)
+               unlink(path);
+
        if (bind(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) {
                save_errno = errno;
                close(s);

-- 
Best Regards
Nan Xiao

Reply via email to