Skip to content

Commit 2bf477e

Browse files
authored
Merge pull request #2 from treydock/lua53
Support `os.execute()` result format change in Lua >5.1
2 parents ca509f6 + a7e518b commit 2bf477e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

gpu_cmode.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ function slurm_spank_task_init_privileged(spank)
130130
cmode, device_ids)
131131
local cmd = nvs_path .. " -c " .. cmodes_index[cmode] ..
132132
" -i " .. device_ids
133-
local ret = tonumber(os.execute(cmd))
133+
local ret = 0
134+
if _VERSION <= 'Lua 5.1' then
135+
ret = tonumber(os.execute(cmd))
136+
else
137+
_, _, ret = os.execute(cmd)
138+
end
134139
SPANK.log_debug(myname .. ": DEBUG: cmd = %s\n", cmd)
135140
SPANK.log_debug(myname .. ": DEBUG: ret = %s\n", ret)
136141

@@ -174,7 +179,12 @@ function slurm_spank_task_exit(spank)
174179
" on GPU(s): %s\n", default_cmode, device_ids)
175180
local cmd = nvs_path .. " -c " .. cmodes_index[default_cmode] ..
176181
" -i " .. device_ids
177-
local ret = tonumber(os.execute(cmd))
182+
local ret = 0
183+
if _VERSION <= 'Lua 5.1' then
184+
ret = tonumber(os.execute(cmd))
185+
else
186+
_, _, ret = os.execute(cmd)
187+
end
178188
SPANK.log_debug(myname .. ": DEBUG: cmd = %s\n", cmd)
179189
SPANK.log_debug(myname .. ": DEBUG: ret = %s\n", ret)
180190

0 commit comments

Comments
 (0)