PrivatetempPrivateactiveExecute a shell command with timeout and memory limits. Automatically kills the process tree if it exceeds time or memory constraints.
Shell command to execute
Execution configuration
Execution result with stdout, stderr, and status
PrivateapplyApplies memory limit to a command using platform-specific methods.
For Java programs, uses -Xmx flag. For Unix, wraps in a ulimit -v subshell.
Windows memory limits are not enforced.
OptionalmemoryLimitMB: numberPrivatenormalizeNormalizes command syntax for the current platform.
On Windows, converts ./foo to .\foo and forward slashes in the executable
path to backslashes to avoid ERROR_PATH_NOT_FOUND (3) from cmd.exe.
Leaves arguments and redirections intact.
PrivatefinalizeFinalizes a timed-out execution: emits the warning, populates the result, and routes to the onTimeout callback or throws.
PrivateisDetects if a process failed due to memory issues. Checks both exit codes (137, SIGABRT) and error messages in stderr.
PrivatefinalizeFinalizes a memory-limit-exceeded execution.
PrivatefinalizeFinalizes a successful execution (exit code 0).
PrivatefinalizeFinalizes a failed execution (non-zero exit code).
PrivatefinalizeFinalizes a spawn-time failure (ENOENT, EACCES, ...).
PrivatekillKills a process and its entire child process tree.
Uses taskkill /T /F on Windows, process-group SIGKILL on Unix.
Falls back to single-process kill if the group call fails.
Execute a command with input/output file redirection.
Wraps the execute method with shell < / > redirections.
OptionalinputFile: stringOptionaloutputFile: stringPrivatebuildBuilds a shell command with input/output redirection. Quotes paths to survive spaces and normalizes them for the current platform.
OptionalinputFile: stringOptionaloutputFile: stringRegister a temporary file for tracking.
Clean up all active processes and clear temp file registry. On Windows, waits briefly for file handles to be released.
PrivatekillGet a copy of the registered temporary files list.
Command executor for running external programs with resource constraints. Manages process lifecycle, timeout enforcement, memory limits, and cleanup. Supports cross-platform execution (Unix/Windows) with platform-specific tree-kill.
CommandExecutor
Example