NAME
Developer::Dashboard::CommandRunner - spawn, poll, signal, and terminate a collector-owned external command process
PURPOSE
Runs one shell command as an owned child process with captured stdout/ stderr, a bounded timeout, and complete subtree cleanup on POSIX and Windows, and provides the pid-file/signal-forwarding contract that keeps that cleanup reachable from a signal handler.
WHY IT EXISTS
Extracted from lib/Developer/Dashboard/CollectorRunner.pm (DD-947, itself part of DD-641's oversized-module finding): this cluster of ten functions was confirmed to have zero dependency on CollectorRunner's own instance state before the move, making it a safe, cohesive, low-coupling piece to give its own module rather than leaving it inside an already 1963-line file. CollectorRunner.pm keeps thin one-line forwarder methods at every original call site, so nothing outside this module changed.
WHEN TO USE
Use this module directly (as plain function calls, no object) whenever spawning an owned, timeout-bounded external command with reliable subtree cleanup is needed - not only from CollectorRunner.
HOW TO USE
Call run_command(source => $shell_cmd, cwd => $dir, env => \%env, timeout_ms => $ms) for the whole spawn-capture-timeout-cleanup flow. The other nine functions are its own internal building blocks, exposed individually because CollectorRunner's forwarders and this module's own test suite call them directly too.
WHAT USES IT
lib/Developer/Dashboard/CollectorRunner.pm's forwarder methods, and t/199-commandrunner-coverage.t.
EXAMPLES
Example 1:
my ( $stdout, $stderr, $exit, $timed_out ) = Developer::Dashboard::CommandRunner::run_command(
source => 'echo hi',
cwd => '/tmp',
env => {},
timeout_ms => 5000,
);
Example 2:
Developer::Dashboard::CommandRunner::terminate_command_process($pid);