模块 posix

require "posix"

API(摘要,来自 builtins/luaposix)

posix 是完整 POSIX 接口绑定(luaposix),通过 require "posix" 加载,仅 POSIX 系统可用。以下为常用 API 摘要;完整清单见 luaposix 文档。

API实现说明
API说明

示例

local posix = require "posix"
local pid = posix.fork()
if pid == 0 then
  print("child pid", posix.getpid())
  os.exit(0)
else
  local wpid, status = posix.wait()
  print("child", wpid, "exit", status)
end
local st = posix.stat("/etc/hosts")
print(st.type, st.size)
local r, w = posix.pipe()
posix.write(w, "hello")
print(posix.read(r, 5))
← 返回模块索引