From 94a76269aaf313e2d6dcf9a08ed1e697302d8d89 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Thu, 27 Oct 2022 15:30:06 +0800 Subject: [PATCH] Fix #1668 --- lualib-src/lua-cluster.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lualib-src/lua-cluster.c b/lualib-src/lua-cluster.c index da671278..668bb1f1 100644 --- a/lualib-src/lua-cluster.c +++ b/lualib-src/lua-cluster.c @@ -603,6 +603,11 @@ lnodename(lua_State *L) { pid_t pid = getpid(); char hostname[256]; if (gethostname(hostname, sizeof(hostname))==0) { + int i; + for (i=0; hostname[i]; i++) { + if (hostname[i] <= ' ') + hostname[i] = '_'; + } lua_pushfstring(L, "%s%d", hostname, (int)pid); } else { lua_pushfstring(L, "noname%d", (int)pid);