mirror of
https://github.com/lune-org/lune.git
synced 2025-04-07 20:10:55 +01:00
chore(types): add spawn example in process docs
This commit is contained in:
parent
48760b6a0f
commit
d3cda4be0c
1 changed files with 14 additions and 1 deletions
|
@ -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 = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue