summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-07 23:30:49 +0800
committerruki <[email protected]>2020-02-07 22:45:57 +0800
commitb59b8efc9b851dd0c326efc78187b811f6057d0c (patch)
tree0e70c4bed6a3f5330b20507fc5e56dae3eaff9b5
parent5cd2e08845765fb1e21b72f22e2707f7e8233b7b (diff)
improve os.exit
-rw-r--r--xmake/actions/build/statistics.lua5
-rw-r--r--xmake/core/base/os.lua13
2 files changed, 12 insertions, 6 deletions
diff --git a/xmake/actions/build/statistics.lua b/xmake/actions/build/statistics.lua
index 729af55e7..7bdcab5cb 100644
--- a/xmake/actions/build/statistics.lua
+++ b/xmake/actions/build/statistics.lua
@@ -89,10 +89,7 @@ function post()
try
{
function ()
- local proc = process.openv("xmake", argv, {stdout = path.join(os.tmpdir(), projectname .. ".stats.log")})
- if proc ~= nil then
- proc:close()
- end
+ process.openv("xmake", argv, {stdout = path.join(os.tmpdir(), projectname .. ".stats.log")}):close()
end
}
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index a2c6eb3be..5daefc471 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -33,6 +33,7 @@ local process = require("base/process")
-- save original interfaces
os._uid = os._uid or os.uid
os._gid = os._gid or os.gid
+os._exit = os._exit or os.exit
os._mkdir = os._mkdir or os.mkdir
os._rmdir = os._rmdir or os.rmdir
os._tmpdir = os._tmpdir or os.tmpdir
@@ -550,6 +551,16 @@ function os.tmpfile(key)
return path.join(os.tmpdir(), "_" .. (hash.uuid4(key):gsub("-", "")))
end
+-- exit program
+function os.exit(...)
+
+ -- kill all pending processes first
+ process.killall()
+
+ -- do exit
+ return os._exit(...)
+end
+
-- run command
function os.run(cmd)
@@ -918,8 +929,6 @@ end
-- check the current command is running as root
function os.isroot()
-
- -- check it
return os.uid().euid == 0
end