Pārlūkot izejas kodu

Merge pull request #4462 from A1029384756/master

Added Unlinking Section to Posix Socket Binding Documentation
Laytan 10 mēneši atpakaļ
vecāks
revīzija
e03f998c27
1 mainītis faili ar 6 papildinājumiem un 0 dzēšanām
  1. 6 0
      core/sys/posix/sys_socket.odin

+ 6 - 0
core/sys/posix/sys_socket.odin

@@ -48,6 +48,12 @@ foreign libc {
 		addr.sun_family = .UNIX
 		copy(addr.sun_path[:], "/somepath\x00")
 
+		/*
+			unlink the socket before binding in case
+			of previous runs not cleaning up the socket
+		*/
+		posix.unlink("/somepath")
+
 		if posix.bind(sfd, (^posix.sockaddr)(&addr), size_of(addr)) != .OK {
 			/* Handle error */
 		}