summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaikari <[email protected]>2026-01-27 05:45:37 +0300
committerSaikari <[email protected]>2026-01-27 05:45:37 +0300
commit6e6cf755b207fe128e6e8a534d3df15f56d9c8a4 (patch)
tree6f2292e9e2682305dae7337bb37a69fb7d8df8b4
parent14b0f24fc76004d1498fa7f85a6c2377b2fbd722 (diff)
refactor tty.shell to use os.tmpfile and os.runv for improved file handling
-rw-r--r--xmake/core/base/tty.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua
index 51c301ab4..27788419b 100644
--- a/xmake/core/base/tty.lua
+++ b/xmake/core/base/tty.lua
@@ -263,8 +263,8 @@ function tty.shell()
for i = 1, 10 do
local stat = io.readfile("/proc/" .. pid .. "/stat")
if not stat or #stat == 0 then
- local tmpfile = path.join(os.tmpdir(), "xmake_stat_" .. os.getpid())
- os.execv("cp", {"/proc/" .. pid .. "/stat", tmpfile})
+ local tmpfile = os.tmpfile()
+ os.runv("cp", {"/proc/" .. pid .. "/stat", tmpfile})
stat = io.readfile(tmpfile)
os.rm(tmpfile)
end
@@ -299,8 +299,8 @@ function tty.shell()
if not shell_path and os.isfile("/proc/" .. ppid .. "/comm") then
shell_name = io.readfile("/proc/" .. ppid .. "/comm")
if not shell_name or #shell_name == 0 then
- local tmpfile = path.join(os.tmpdir(), "xmake_comm_" .. os.getpid())
- os.execv("cp", {"/proc/" .. ppid .. "/comm", tmpfile})
+ local tmpfile = os.tmpfile()
+ os.runv("cp", {"/proc/" .. ppid .. "/comm", tmpfile})
shell_name = io.readfile(tmpfile)
os.rm(tmpfile)
end