capture_processHow to REA Process Behavior: Terminal PTY Capture, Filesystem Traces & Exit Codes
Observe command-line tools and background processes dynamically: run targets inside an isolated pseudo-terminal (PTY), capture ANSI terminal escape sequences, record filesystem modifications, and compare execution behavior across inputs.
In this official REA guide for Process Behavior & PTY Capture, AI coding agents (Claude Code, Cursor, Windsurf) execute 'rea capture-process --command "./cli_tool --verify" --json' to safely extract file layout, symbols, and code logic without launching unverified binaries.
The Problem & Target Artifact
CLI application analysis or suspicious tool evaluation: You have a closed-source binary tool or installer that expects terminal input. You need to record its exact terminal screen output, exit status, and dropped files without altering your shell environment.
Natural Language Agent Instructions
Copy and paste this prompt directly into your AI coding agent when REA is registered via Model Context Protocol (MCP):
Execute ./cli_tool inside REA's process capture PTY. Feed it test input, capture its terminal output streams, and record any files created in /tmp.Run REA Analysis Command
Execute the following command in your terminal or inspect the MCP JSON-RPC call executed by your agent:
rea capture-process --command "./cli_tool --verify" --jsonWhat REA Extracts & Returns
Captured Process Telemetry & PTY Output
The verified findings and synthesized clean-room structures generated from this investigation:
{
"command": "./cli_tool --verify",
"exit_code": 0,
"duration_ms": 420,
"pty_output": "Connecting to server... OK\nLicense verified: ACTIVE\n[+] Initializing sandbox...",
"filesystem_effects": [
{ "path": "/tmp/cli_tool.lock", "action": "created_and_removed" },
{ "path": "~/.config/cli_tool/cache.db", "action": "written", "bytes": 4096 }
]
}Isolated Pseudo-Terminal (PTY) Allocation
Many CLI utilities check `isatty(STDIN_FILENO)` and refuse to run or suppress output if piped through standard stdin/stdout. REA allocates a native pseudo-terminal master/slave pair (openpty), simulating a real user terminal session while capturing raw ANSI control sequences into verifiable Evidence ledgers.