aboutsummaryrefslogtreecommitdiff
path: root/core/net/socket_linux.odin
diff options
context:
space:
mode:
authorflysand7 <thebumboni@gmail.com>2024-07-18 00:34:53 +1100
committerflysand7 <thebumboni@gmail.com>2024-07-18 22:50:47 +1100
commit4dcb75af6d5bed82038c4ad3e16eaa17bb8d5237 (patch)
tree5f6557b86e2b56e13f41df214d3d2dfefa64a89a /core/net/socket_linux.odin
parent0bb4cc6ce5230ef2fa47a1b614d359710ea4271a (diff)
Make all handles non-inheritable by default
The sockets are left as non-inheritable because they never should be inherited.
Diffstat (limited to 'core/net/socket_linux.odin')
-rw-r--r--core/net/socket_linux.odin6
1 files changed, 3 insertions, 3 deletions
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)