The open source OpenXR runtime

ipc/client: Open socket with SOCK_CLOEXEC.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2470>

authored by

Paul Gofman and committed by
Marge Bot
6d04e12b ce69d750

+9 -1
+9 -1
src/xrt/ipc/client/ipc_client_connection.c
··· 206 206 static bool 207 207 ipc_client_socket_connect(struct ipc_connection *ipc_c) 208 208 { 209 + #ifdef SOCK_CLOEXEC 210 + // Make sure the socket is not inherited by child processes. For one, when there is an fd to the socket 211 + // in the child process closing the client connection (or killing the connected process) 212 + // may not be seen in the server as client disconnection. 213 + const int flags = SOCK_CLOEXEC; 214 + #else 215 + const int flags = 0; 216 + #endif 209 217 struct sockaddr_un addr; 210 218 int ret; 211 219 212 220 213 221 // create our IPC socket 214 222 215 - ret = socket(PF_UNIX, SOCK_STREAM, 0); 223 + ret = socket(PF_UNIX, SOCK_STREAM | flags, 0); 216 224 if (ret < 0) { 217 225 IPC_ERROR(ipc_c, "Socket Create Error!"); 218 226 return false;