From d3cda4be0cb6e934b15e725ddbdba11f6d912e25 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Mon, 10 Jun 2024 09:08:57 +0530 Subject: [PATCH] chore(types): add spawn example in process docs --- types/process.luau | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/types/process.luau b/types/process.luau index a60f1d9..4a6e9f1 100644 --- a/types/process.luau +++ b/types/process.luau @@ -162,7 +162,7 @@ export type ExecuteResult = { -- Getting the current os and processor architecture print("Running " .. process.os .. " on " .. process.arch .. "!") - -- Executeing a child process + -- Executing a command local result = process.exec("program", { "cli argument", "other cli argument" @@ -172,6 +172,19 @@ export type ExecuteResult = { else print(result.stderr) 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 = {}