From 4dcb75af6d5bed82038c4ad3e16eaa17bb8d5237 Mon Sep 17 00:00:00 2001 From: flysand7 Date: Thu, 18 Jul 2024 00:34:53 +1100 Subject: Make all handles non-inheritable by default The sockets are left as non-inheritable because they never should be inherited. --- core/net/socket_linux.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/net/socket_linux.odin') diff --git a/core/net/socket_linux.odin b/core/net/socket_linux.odin index a5d553234..350d3947c 100644 --- a/core/net/socket_linux.odin +++ b/core/net/socket_linux.odin @@ -117,7 +117,7 @@ _wrap_os_addr :: proc "contextless" (addr: linux.Sock_Addr_Any)->(Endpoint) { _create_socket :: proc(family: Address_Family, protocol: Socket_Protocol) -> (Any_Socket, Network_Error) { family := _unwrap_os_family(family) proto, socktype := _unwrap_os_proto_socktype(protocol) - sock, errno := linux.socket(family, socktype, {}, proto) + sock, errno := linux.socket(family, socktype, {.CLOEXEC}, proto) if errno != .NONE { return {}, Create_Socket_Error(errno) } @@ -132,7 +132,7 @@ _dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_optio } // Create new TCP socket os_sock: linux.Fd - os_sock, errno = linux.socket(_unwrap_os_family(family_from_endpoint(endpoint)), .STREAM, {}, .TCP) + os_sock, errno = linux.socket(_unwrap_os_family(family_from_endpoint(endpoint)), .STREAM, {.CLOEXEC}, .TCP) if errno != .NONE { // TODO(flysand): should return invalid file descriptor here casted as TCP_Socket return {}, Create_Socket_Error(errno) @@ -172,7 +172,7 @@ _listen_tcp :: proc(endpoint: Endpoint, backlog := 1000) -> (TCP_Socket, Network ep_address := _unwrap_os_addr(endpoint) // Create TCP socket os_sock: linux.Fd - os_sock, errno = linux.socket(ep_family, .STREAM, {}, .TCP) + os_sock, errno = linux.socket(ep_family, .STREAM, {.CLOEXEC}, .TCP) if errno != .NONE { // TODO(flysand): should return invalid file descriptor here casted as TCP_Socket return {}, Create_Socket_Error(errno) -- cgit v1.2.3