← all modules

Sky.Core.Process

Sky.Core.Process
  Sky.Core.Process — subprocess execution (Layer 3 Sky source).

Types
  type Process
  type Command
  type alias CommandSpec = { program : String , args : List String , env : List ( String, String ) , clearEnv : Bool , cwd : String , pty : Bool , ptyCols : Int , ptyRows : Int , bufferSize : Int }
  type Stream = Stdout | Stderr
  type alias Chunk = { data : String , from : Int , next : Int , dropped : Bool , eof : Bool }
  type Event = Output Stream Chunk | Exited ExitStatus
  type ExitStatus = ExitCode Int | Signalled Int
  type Signal = Interrupt | Terminate | Kill | Hangup
  type alias Screen = { changed : Bool , frame : Value , eof : Bool }

Values
  close : Process -> Task Error ()
      Kill the child if it still runs, wait for it, release its pipes and
  closeStdin : Process -> Task Error ()
      Close the child's stdin, so it reads end of file. With a PTY this types
  command : String -> Command
      `command program` — run `program` (a path, or a name looked up on
  events : Process -> (Event -> msg) -> Sub msg
      `events process toMsg` — a subscription that delivers the output as it
  kill : Process -> Signal -> Task Error ()
      Send a signal to the child and every process in its group. Signalling a
  pid : Process -> Task Error Int
      The child's operating-system process id.
  readFrom : Process -> Stream -> Int -> Task Error Chunk
      `readFrom process stream offset` — the output of `stream` from `offset`
  readWithin : Int -> Process -> Stream -> Int -> Task Error Chunk
      `readWithin ms process stream offset` — `readFrom`, but return after
  resize : Process -> { cols : Int , rows : Int } -> Task Error ()
      Change the PTY size. `Err InvalidInput` without a PTY.
  run : String -> List String -> Task Error String
      `run command args` — execute a subprocess, return its stdout.
  screen : { view : String , gen : Int , full : Bool , waitMs : Int } -> Process -> Task Error Screen
      `screen request process` — the next frame of the process's terminal
  spawn : Command -> Task Error Process
      `spawn command` — start the child. Fails with `NotFound` when the
  wait : Process -> Task Error ExitStatus
      Wait until the child exits and return how it ended.
  withArgs : List String -> Command -> Command
      Set the arguments (replaces any set before).
  withBufferSize : Int -> Command -> Command
      Keep this many bytes of each output stream (default 1 MiB).
  withClearEnv : Command -> Command
      Start from an empty environment instead of the parent's: the child sees
  withCwd : String -> Command -> Command
      Run the child in this working directory.
  withEnv : List ( String, String ) -> Command -> Command
      Add environment variables. A name that is already set is replaced.
  withPty : { cols : Int , rows : Int } -> Command -> Command
      Run the child on a pseudo-terminal of this size (Linux and macOS).
  write : Process -> String -> Task Error ()
      Write to the child's stdin (with a PTY: type into its terminal).