Import std.os.process_child
std.os.process_child
A running child process: its streams, waiting for it, and ending it.
Child, a program that a Command started, which runs beside this one: its Id, its piped streams, a Writer to its stdin and Readers of its stdout and stderr, and Wait, TryWait, and Kill, with the ExitStatus that says how it ended.
Examples
Local child = Try Command("sort").Stdin(Stdio.PIPED).Stdout(Stdio.PIPED).Spawn()
Local input = child.Stdin
Local output = child.Stdout
If input == Null || output == Null Then Return
Try input.WriteText("pear\napple\n")
input.Close()
Print(Try ReadAllText(output))
Print(child.Wait())std/os/process_child.fb
Types
ExitStatus
struct
Public Struct ExitStatus Implements Printable
How a child ended: with the code it exited with, or by a signal, as Kill ends one.
std/os/process_child.fb, line 45
-
The code it exited with, which on Windows is from 0 to 4294967295, or Null when a signal ended it.
-
The signal that ended it, as 9 for Kill, on Windows too, or Null when it exited.
-
Whether it exited with 0, which says it went well.
-
How it ended, as "exit code 0" or "signal 9".
Child
class
Public Class Child
A program that a Command started, which runs beside this one until it ends, whether or not this program waits for it. Letting go of it, and of its streams, closes its pipes, but doesn't end it.
std/os/process_child.fb, line 77
-
Its stdin, when the Command piped it, a Writer to what the child reads.
-
Its stdout, when the Command piped it, a Reader of what the child writes there.
-
Its stderr, when the Command piped it.
-
The OS's number for its process.
-
Waits for it to end, and gives how it did. Its stdin closes first, so a child that reads to its end doesn't wait for more.
-
Wait's Async twin, which waits on the main thread instead of blocking it.
-
How it ended, or Null while it runs.
-
Ends it at once, unless it's ended already: by SIGKILL, or on Windows TerminateProcess, either way with Signal 9. Throws an IOError when the OS won't.
ChildInput
class
Public Class ChildInput Implements Writer
A child's stdin, which writes to what it reads. Bytes go to the child as they're written, and Write returns once they have.
std/os/process_child.fb, line 134
-
Writes from's bytes to the child's stdin. Throws an IOError once the stream is closed, or the child has gone.
-
Write's Async twin, which writes on the I/O thread while the main thread goes on.
-
Closes it once what's written has gone, so the child reads to its end. Closing it again does nothing.
ChildOutput
class
Public Class ChildOutput Implements Reader
A child's stdout or stderr, which reads what it writes there, as it comes, until it ends or closes it.
std/os/process_child.fb, line 175
-
Reads up to into.Count bytes of what the child wrote into the start of
into, waiting while it's written nothing new, and gives how many, or 0 once the child has closed the stream. -
Read's Async twin, which waits on the I/O thread while the main thread goes on.
Report an issue with this page or with FutureBlitz on GitHub.