process

package
v1.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package process provides subprocess execution primitives.

This extension is NOT included in the Console profile. Embedders must opt in explicitly with WithExtension(process.Extension) or use WithProfile(KitchenSink).

Spawning asks two KINDS of question, and both must be answered before a child runs.

The CAPABILITY question is security.ResourceProcess with the command as target: ActionExec for process-spawn (structured, no shell), ActionExecShell for system (shell command string). It asks whether this program may spawn a subprocess at all.

The OBJECT questions are security.ResourceFile with ActionExec — the chmod x bit — asked twice: once on the binary that will actually run, and once on the directory the child will start in (POSIX x on a directory is traverse). They ask which binary, from where. Without them a path-confining authorizer never sees either: the capability request carries a command STRING, and /bin/sh is a general-purpose unconfined file accessor that no root ever bounded.

Two details the gates depend on, both in prim_process.go:

  • The gated binary is cmd.Path AFTER exec.Command's LookPath resolution, not the caller's string, joined against cmd.Dir when relative — otherwise the authorized file and the executed file can differ.
  • The child's start directory is the authorizer's ConfinementRoot when it reports one, not the host's inherited working directory.

Shell Execution

  • system

Structured Process Control

  • process-spawn, process-wait, process-kill
  • process-stdout, process-stderr, process-stdin

Process Predicates

  • process?

Use Extension or AddToRegistry to register all primitives.

Index

Constants

This section is empty.

Variables

View Source
var AddToRegistry = Builder.AddToRegistry

AddToRegistry registers all process primitives.

View Source
var Builder = registry.NewRegistryBuilder(addPrimitives)

Builder aggregates all process registration functions.

View Source
var Extension = registry.NewDescribedExtension("process",
	"OS processes: shell command execution, subprocess spawn/wait/kill with piped stdio.",
	AddToRegistry)

Extension is the process execution extension.

View Source
var PrimProcessStderr = helpers.MakeUnaryAccessor(werr.ErrNotAProcess, "process-stderr", func(proc *values.Process) values.Value {
	return proc.Stderr()
})

PrimProcessStderr implements the (process-stderr) primitive.

View Source
var PrimProcessStdin = helpers.MakeUnaryAccessor(werr.ErrNotAProcess, "process-stdin", func(proc *values.Process) values.Value {
	return proc.Stdin()
})

PrimProcessStdin implements the (process-stdin) primitive.

View Source
var PrimProcessStdout = helpers.MakeUnaryAccessor(werr.ErrNotAProcess, "process-stdout", func(proc *values.Process) values.Value {
	return proc.Stdout()
})

PrimProcessStdout implements the (process-stdout) primitive.

Functions

func PrimProcessKill

func PrimProcessKill(mc machine.CallContext) error

PrimProcessKill implements the (process-kill) primitive. Sends a signal to the process. Signal is a symbol: term, kill, int, hup.

func PrimProcessQ

func PrimProcessQ(mc machine.CallContext) error

PrimProcessQ implements the (process?) predicate.

func PrimProcessSpawn

func PrimProcessSpawn(mc machine.CallContext) error

PrimProcessSpawn implements the (process-spawn) primitive. Creates a subprocess with stdin/stdout/stderr pipes.

A spawned child is recorded against the calling engine's namespace so Engine.Close can kill and reap it (close.go). A spawn that failed is not recorded.

func PrimProcessWait

func PrimProcessWait(mc machine.CallContext) error

PrimProcessWait implements the (process-wait) primitive. Blocks until the process exits and returns the exit code.

The wait goes through values.Process.Wait, not cmd.Wait: two SRFI-18 threads in (process-wait p), or one of them racing Engine.Close's reaper, would otherwise wait4 the same pid twice and tear cmd.ProcessState between them.

func PrimSystem

func PrimSystem(mc machine.CallContext) error

PrimSystem implements the (system) primitive. Runs a shell command via /bin/sh -c and returns the exit code.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL