ProcessHandler

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

ShotInstancenot creatablecomingPrograms

Up and coming

Start a program, read its output line by line, write to it and stop it cleanly, or pick up one that is still running.

ProcessService's StartAsync gives one, and AttachAsync reaches a program started earlier, by a previous run of your tool: no output or input then, but Running a project, Exited and the stops work. Each is a child of ProcessService, named by the Name option or else the program's file name, and its pid is checked by its creation time, so a reused pid never counts.

Passes shot check todayLuau
local function example(x : ProcessHandler)
	x.Line:Connect(function(line : string, stream : Stream)
		print(stream, line)
	end)
	local code : number = x:StopAsync(10)
	print(code)
end

Properties

NameTypeDefaultDescription
Programstring
Arguments{ string }
WorkingFolderstring
CommandLinestring?
Pidnumber?
ParentPidnumber?
CreatedAtnumberThe process's creation time, which IsAliveAsync checks so a reused pid never counts as this program.
StartedAtnumberWhen it started, in seconds since 1970.
Running a projectboolean
ExitCodenumber?
AttachedbooleanWhether it was reached by AttachAsync; such a program has no output or input, but Running, Exited and the stops work.

Methods

NameArgumentsReturnsDescription
Write(text: string)()Sends text to the program's input, queued in order; never waits.
WriteLine(text: string)()Sends the text and a line end, so a program that reads JSON lines gets one message per call.
CloseInput()()
IsAliveAsync
yields
()booleanWhether it still runs: the same pid with the same creation time, so a reused pid never counts.
GetChildProcessesAsync
yields
(){ ProcessHandler }
GetStatsAsync
yields
()(ProcessStats?, string?)Processor and memory use of the program and everything it started.
WaitAsync
yields
(timeout: number?)number?Waits for the program to end and returns its exit code, or nil when timeout seconds pass first.
StopAsync
yields
(grace: number?)numberCloses its input, waits up to grace seconds (default 10) for it to end, then kills it and everything it started.
KillAsync
yields
()numberKills it and everything it started, now.

Events

NamePassesDescription
Line(string, Stream)Fires with each line of output, without its line end, and its stream: "stdout" or "stderr".
Exited(number)Fires with the exit code after the last line, also for a program this tool didn't start.
From ShotInstance 33