Excessibility.MCP.Subprocess (Excessibility v0.14.0)

View Source

Subprocess execution with proper timeout handling.

Unlike System.cmd/3 wrapped in Task.yield/shutdown, this module actually kills the underlying OS process when a timeout occurs.

Summary

Functions

Runs a command with optional timeout.

Functions

run(cmd, args, opts \\ [])

Runs a command with optional timeout.

Options

  • :timeout - Timeout in milliseconds. If nil, no timeout is applied.
  • :cd - Working directory for the command.
  • :env - Environment variables as a list of {key, value} tuples.
  • :stderr_to_stdout - If true, redirects stderr to stdout (default: false).

Returns

  • {output, exit_code} on success or timeout
  • On timeout, returns {"Error: Command timed out after N seconds", 124}

Examples

iex> Subprocess.run("echo", ["hello"], timeout: 5000)
{"hello\n", 0}

iex> Subprocess.run("sleep", ["10"], timeout: 100)
{"Error: Command timed out after 0 seconds", 124}