From 74b1f5f5aa4934bb8dada2e511ab7c9238e092f9 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Mon, 3 Aug 2026 18:57:08 +0200 Subject: [PATCH] adapt get_info --- tools/server/server-tools.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/server/server-tools.cpp b/tools/server/server-tools.cpp index 5d18250ecd..7fc5885091 100644 --- a/tools/server/server-tools.cpp +++ b/tools/server/server-tools.cpp @@ -1309,13 +1309,16 @@ struct server_tool_get_info : server_tool { json invoke(json params, server_tool::stream *) const override { auto io = make_tools_io(params); + // inside docker, we always use the linux command #ifdef _WIN32 - auto res = io->run({"cmd", "/c", "ver"}, 4096, 5); + std::vector args = params.contains("docker_container_id") + ? std::vector{"uname", "-a"} + : std::vector{"cmd", "/c", "ver"}; #else - auto res = io->run({"uname", "-a"}, 4096, 5); + std::vector args = {"uname", "-a"}; #endif - // "ver" prints a blank line before the version, so the output is stripped on both ends; - // a failed spawn or a timeout leaves a diagnostic in res.output, which is not an OS name + + auto res = io->run(args, 4096, 5); std::string os_info = res.exit_code == 0 && !res.timed_out ? string_strip(res.output) : "unknown"; std::string cwd = json_value(params, "cwd", std::string());