summaryrefslogtreecommitdiff
path: root/xmake/core/base/os.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-05 23:43:18 +0800
committerruki <[email protected]>2022-04-05 23:43:18 +0800
commitc7e96adbab7d833ca63ac4fb73061f9949a46de0 (patch)
treebc4d9695f18c0d1525e4f8029013b5d5921faa8a /xmake/core/base/os.lua
parent4724bc52df2b22357103d6569f9664c5651a3ebe (diff)
add os.getpid
Diffstat (limited to 'xmake/core/base/os.lua')
-rw-r--r--xmake/core/base/os.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 39530eb0f..daff4d75b 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._getuid = os._getuid or os.getuid or os.uid -- for old core
os._getgid = os._getgid or os.getgid or os.gid
+os._getpid = os._getpid or os.getpid
os._exit = os._exit or os.exit
os._mkdir = os._mkdir or os.mkdir
os._rmdir = os._rmdir or os.rmdir
@@ -991,6 +992,16 @@ function os.getgid(...)
return os._GID
end
+-- get pid
+function os.getpid(...)
+ local pid = os._PID
+ if pid == nil then
+ pid = os._getpid()
+ os._PID = pid
+ end
+ return pid
+end
+
-- check the current command is running as root
function os.isroot()
return os.getuid().euid == 0