The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Expose no_stdin option through interface

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

+29 -17
+4 -1
src/xrt/ipc/server/ipc_server.h
··· 335 335 * @public @memberof ipc_server_mainloop 336 336 */ 337 337 int 338 - ipc_server_mainloop_init(struct ipc_server_mainloop *ml); 338 + ipc_server_mainloop_init(struct ipc_server_mainloop *ml, bool no_stdin); 339 339 340 340 /*! 341 341 * @brief Poll the mainloop. ··· 423 423 * User data passed to callbacks. 424 424 */ 425 425 void *callback_data; 426 + 427 + //! Disable listening on stdin for server stop. 428 + bool no_stdin; 426 429 }; 427 430 428 431 /*!
+3
src/xrt/ipc/server/ipc_server_interface.h
··· 39 39 40 40 //! Flag whether runtime should exit on app disconnect. 41 41 bool exit_on_disconnect; 42 + 43 + //! Disable listening on stdin for server stop. 44 + bool no_stdin; 42 45 }; 43 46 44 47 /*!
+1 -1
src/xrt/ipc/server/ipc_server_mainloop_android.c
··· 139 139 } 140 140 141 141 int 142 - ipc_server_mainloop_init(struct ipc_server_mainloop *ml) 142 + ipc_server_mainloop_init(struct ipc_server_mainloop *ml, bool no_stdin) 143 143 { 144 144 int ret = init_pipe(ml); 145 145 if (ret < 0) {
+5 -12
src/xrt/ipc/server/ipc_server_mainloop_linux.c
··· 1 1 // Copyright 2020-2021, Collabora, Ltd. 2 + // Copyright 2025, NVIDIA CORPORATION. 2 3 // SPDX-License-Identifier: BSL-1.0 3 4 /*! 4 5 * @file ··· 46 47 #include <systemd/sd-daemon.h> 47 48 #endif 48 49 49 - /* 50 - * "XRT_NO_STDIN" option disables stdin and prevents monado-service from terminating. 51 - * This could be useful for situations where there is no proper or in a non-interactive shell. 52 - * Two example scenarios are: 53 - * * IDE terminals, 54 - * * Some scripting environments where monado-service is spawned in the background 55 - */ 56 - DEBUG_GET_ONCE_BOOL_OPTION(skip_stdin, "XRT_NO_STDIN", false) 57 50 58 51 /* 59 52 * ··· 175 168 } 176 169 177 170 static int 178 - init_epoll(struct ipc_server_mainloop *ml) 171 + init_epoll(struct ipc_server_mainloop *ml, bool no_stdin) 179 172 { 180 173 int ret = epoll_create1(EPOLL_CLOEXEC); 181 174 if (ret < 0) { ··· 186 179 187 180 struct epoll_event ev = {0}; 188 181 189 - if (!ml->launched_by_socket && !debug_get_bool_option_skip_stdin()) { 182 + if (!ml->launched_by_socket && !no_stdin) { 190 183 // Can't do this when launched by systemd socket activation by 191 184 // default. 192 185 // This polls stdin. ··· 265 258 } 266 259 267 260 int 268 - ipc_server_mainloop_init(struct ipc_server_mainloop *ml) 261 + ipc_server_mainloop_init(struct ipc_server_mainloop *ml, bool no_stdin) 269 262 { 270 263 IPC_TRACE_MARKER(); 271 264 ··· 275 268 return ret; 276 269 } 277 270 278 - ret = init_epoll(ml); 271 + ret = init_epoll(ml, no_stdin); 279 272 if (ret < 0) { 280 273 ipc_server_mainloop_deinit(ml); 281 274 return ret;
+3 -2
src/xrt/ipc/server/ipc_server_mainloop_windows.cpp
··· 1 1 // Copyright 2022, Magic Leap, Inc. 2 2 // Copyright 2020-2022, Collabora, Ltd. 3 + // Copyright 2025, NVIDIA CORPORATION. 3 4 // SPDX-License-Identifier: BSL-1.0 4 5 /*! 5 6 * @file ··· 218 219 { 219 220 IPC_TRACE_MARKER(); 220 221 221 - if (_kbhit()) { 222 + if (!vs->no_stdin && _kbhit()) { 222 223 U_LOG_E("console input! exiting..."); 223 224 ipc_server_handle_shutdown_signal(vs); 224 225 return; ··· 249 250 } 250 251 251 252 int 252 - ipc_server_mainloop_init(struct ipc_server_mainloop *ml) 253 + ipc_server_mainloop_init(struct ipc_server_mainloop *ml, bool no_stdin) 253 254 { 254 255 IPC_TRACE_MARKER(); 255 256
+13 -1
src/xrt/ipc/server/ipc_server_process.c
··· 61 61 DEBUG_GET_ONCE_NUM_OPTION(exit_when_idle_delay_ms, "IPC_EXIT_WHEN_IDLE_DELAY_MS", 5000) 62 62 DEBUG_GET_ONCE_LOG_OPTION(ipc_log, "IPC_LOG", U_LOGGING_INFO) 63 63 64 + /* 65 + * "XRT_NO_STDIN" option disables stdin and prevents monado-service from terminating. 66 + * This could be useful for situations where there is no proper or in a non-interactive shell. 67 + * Two example scenarios are: 68 + * * IDE terminals, 69 + * * Some scripting environments where monado-service is spawned in the background 70 + */ 71 + DEBUG_GET_ONCE_BOOL_OPTION(no_stdin, "XRT_NO_STDIN", false) 72 + 64 73 65 74 /* 66 75 * ··· 504 513 xret = xrt_instance_create(NULL, &s->xinst); 505 514 IPC_CHK_WITH_GOTO(s, xret, "xrt_instance_create", error); 506 515 507 - ret = ipc_server_mainloop_init(&s->ml); 516 + ret = ipc_server_mainloop_init(&s->ml, s->no_stdin); 508 517 if (ret < 0) { 509 518 xret = XRT_ERROR_IPC_MAINLOOP_FAILED_TO_INIT; 510 519 } ··· 1070 1079 1071 1080 // Allocate the server itself. 1072 1081 struct ipc_server *s = U_TYPED_CALLOC(struct ipc_server); 1082 + 1083 + // Can be set by either. 1084 + s->no_stdin = ismi->no_stdin || debug_get_bool_option_no_stdin(); 1073 1085 1074 1086 #ifdef XRT_OS_WINDOWS 1075 1087 timeBeginPeriod(1);