summaryrefslogtreecommitdiff
path: root/xmake/core/base/os.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-12-28 22:34:59 +0800
committerruki <[email protected]>2023-12-28 22:34:59 +0800
commit060626edbf26101044d6ab74f7f1af2fd755dc13 (patch)
treee5271d4e3219a275abe9fe8c01b72a25fdc858fd /xmake/core/base/os.lua
parent5274ebb6ac3b130f820c9b6caf512181fbde37bf (diff)
test process timeout #4544
Diffstat (limited to 'xmake/core/base/os.lua')
-rw-r--r--xmake/core/base/os.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 9bf835456..47cfb98b3 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -860,6 +860,7 @@ function os.execv(program, argv, opt)
-- open command
local ok = -1
+ local errors
local proc = process.openv(filename, argv or {}, openopt)
if proc ~= nil then
@@ -871,9 +872,12 @@ function os.execv(program, argv, opt)
-- wait process
if not opt.detach then
- local waitok, status = proc:wait(-1)
+ local waitok, status = proc:wait(opt.timeout or -1)
if waitok > 0 then
ok = status
+ elseif waitok == 0 and opt.timeout then
+ proc:kill()
+ errors = "wait process timeout"
end
else
ok = 0
@@ -885,7 +889,7 @@ function os.execv(program, argv, opt)
-- cannot execute process
return nil, os.strerror()
end
- return ok
+ return ok, errors
end
-- run command and return output and error data