ProcessHandler
Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.
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.
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)
endProperties
| Name | Type | Default | Description |
|---|---|---|---|
| Program | string | ||
| Arguments | { string } | ||
| WorkingFolder | string | ||
| CommandLine | string? | ||
| Pid | number? | ||
| ParentPid | number? | ||
| CreatedAt | number | The process's creation time, which IsAliveAsync checks so a reused pid never counts as this program. | |
| StartedAt | number | When it started, in seconds since 1970. | |
| Running a project | boolean | ||
| ExitCode | number? | ||
| Attached | boolean | Whether it was reached by AttachAsync; such a program has no output or input, but Running, Exited and the stops work. |
Methods
| Name | Arguments | Returns | Description |
|---|---|---|---|
| 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 | () | boolean | Whether 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?) | number | Closes its input, waits up to grace seconds (default 10) for it to end, then kills it and everything it started. |
| KillAsync yields | () | number | Kills it and everything it started, now. |
Events
| Name | Passes | Description |
|---|---|---|
| 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
ClassNameNameParentAncestryChangedAttributeChangedChangedChildAddedChildRemovedDestroyingAddTagClearAllChildrenCloneDestroyFindFirstAncestorFindFirstAncestorOfClassFindFirstAncestorWhichIsAFindFirstChildFindFirstChildOfClassFindFirstChildWhichIsAGetAttributeGetAttributeChangedSignalGetAttributesGetChildrenGetDescendantsGetFullNameGetPropertyChangedSignalGetTagsHasTagIsAIsAncestorOfIsDescendantOfRemoveTagSetAttribute
