sysproc

package
v0.22.159 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package sysproc — process-group reaping helpers shared across clawtool callsites (Bash tool, Verify tool, hooks subsystem). The pattern mirrors internal/tools/core/exec_unix.go but lives in its own package so non-tool callers (hooks, future plan runner) can reuse it without an import cycle.

Package sysproc — small cross-platform process helpers used by the CLI surface. OpenBrowser launches the user's default browser to a URL via the OS-native handler (xdg-open on Linux, open on macOS, rundll32 on Windows). Used by `clawtool star` when the OAuth flow needs the user to authorise + by `--no-oauth` mode when we just want to land them on the official action page.

The function is intentionally non-blocking: it kicks the OS handler and returns. The handler then forks the user-space browser process; we never inherit that process's exit code, which is the point — the user's browser shouldn't tie up the CLI.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedPlatform = errors.New("sysproc: no browser launcher for this OS")

ErrUnsupportedPlatform is returned when OpenBrowser doesn't have a launcher recipe for the current GOOS. Callers can surface a "copy this URL into your browser" fallback instead of failing hard.

Functions

func ApplyGroup

func ApplyGroup(cmd *exec.Cmd)

ApplyGroup makes cmd run in its own process group so KillGroup can SIGKILL the whole tree (including shell children like `sleep` that would otherwise hold stdio pipes open and stall Wait).

Callers that use exec.CommandContext can additionally set cmd.Cancel themselves to wire context cancellation to the group kill — we deliberately don't touch cmd.Cancel here because plain exec.Command() rejects a non-nil Cancel at Start time.

func ApplyGroupWithCtxCancel

func ApplyGroupWithCtxCancel(cmd *exec.Cmd)

ApplyGroupWithCtxCancel is the CommandContext-friendly variant: it sets Setpgid AND wires cmd.Cancel to the group SIGKILL. Use this when you've created the command via exec.CommandContext and want ctx-cancellation to reap the whole tree.

func KillGroup

func KillGroup(cmd *exec.Cmd)

KillGroup sends SIGKILL to the whole process group cmd.Process leads. Safe to call after Start; no-op when Process is nil.

func OpenBrowser added in v0.22.36

func OpenBrowser(url string) error

OpenBrowser asks the OS to open url in the user's default browser. Returns nil if the launcher process started cleanly (the actual browser may take a moment to render); returns the launcher's error otherwise. Does NOT validate the URL — the caller is responsible for the value's safety.

Types

This section is empty.

Jump to

Keyboard shortcuts

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