sandbox

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package sandbox runs image decoding in an isolated subprocess.

The caller's binary must call MaybeRunWorker() at the very top of main() so the child process can identify itself and apply OS-level restrictions before doing any work:

func main() {
    termimage.MaybeRunWorker()
    // ... normal startup
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(path string) (*image.NRGBA, error)

Decode spawns a sandboxed worker subprocess to decode the image at path. Returns an NRGBA image whose pixels were produced inside the sandbox.

func DecodeBytes added in v0.1.0

func DecodeBytes(data []byte) (*image.NRGBA, error)

DecodeBytes spawns a sandboxed worker subprocess to decode raw image bytes piped over stdin. Used for data: URIs and remote URLs where there is no on-disk file to grant access to.

func DecodeBytesContext added in v0.1.0

func DecodeBytesContext(ctx context.Context, data []byte) (*image.NRGBA, error)

DecodeBytesContext is DecodeBytes with caller-supplied context.

func DecodeContext

func DecodeContext(ctx context.Context, path string) (*image.NRGBA, error)

DecodeContext is Decode with caller-supplied context for cancellation.

func IsWorker

func IsWorker() bool

IsWorker reports whether this process was spawned as a sandbox worker.

func MaybeRunWorker

func MaybeRunWorker()

MaybeRunWorker checks if this process is a worker. If so, it applies OS-level sandbox restrictions, decodes the image from stdin, writes the raw pixel data to stdout, and exits. Call this at the start of main().

Types

This section is empty.

Jump to

Keyboard shortcuts

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