chore(types): add spawn example in process docs

This commit is contained in:
Erica Marigold 2024-06-10 09:08:57 +05:30
parent 48760b6a0f
commit d3cda4be0c
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1

View file

@ -162,7 +162,7 @@ export type ExecuteResult = {
-- Getting the current os and processor architecture -- Getting the current os and processor architecture
print("Running " .. process.os .. " on " .. process.arch .. "!") print("Running " .. process.os .. " on " .. process.arch .. "!")
-- Executeing a child process -- Executing a command
local result = process.exec("program", { local result = process.exec("program", {
"cli argument", "cli argument",
"other cli argument" "other cli argument"
@ -172,6 +172,19 @@ export type ExecuteResult = {
else else
print(result.stderr) print(result.stderr)
end end
-- Spawning a child process
local child = process.spawn("program", {
"cli argument",
"other cli argument"
})
-- Writing to the child process' stdin
child.stdin:write("Hello from Lune!")
-- Reading from the child process' stdout
local data = child.stdout:read()
print(buffer.tostring(data))
``` ```
]=] ]=]
local process = {} local process = {}