Class: Hermetic::Transport::Subprocess
- Inherits:
-
Object
- Object
- Hermetic::Transport::Subprocess
- Defined in:
- lib/hermetic/transport/subprocess.rb
Overview
Host-side process runner: spawns an argv, pipes stdin, and enforces the wall clock with a reaper (never trusts the guest to exit — the pattern ported from Silas's Docker adapter). Returns [stdout, stderr, exit_status, timed_out]; a timeout maps to exit 124 (coreutils convention, matches Silas TIMEOUT_EXIT). The low-level capture is injectable so the tuple/timeout contract is unit-testable with no real processes.
Constant Summary collapse
- TIMEOUT_EXIT =
124
Instance Method Summary collapse
- #call(argv, stdin: nil, timeout: 30) ⇒ Object
-
#initialize(capture: nil) ⇒ Subprocess
constructor
A new instance of Subprocess.
Constructor Details
#initialize(capture: nil) ⇒ Subprocess
Returns a new instance of Subprocess.
15 16 17 |
# File 'lib/hermetic/transport/subprocess.rb', line 15 def initialize(capture: nil) @capture = capture || method(:popen_capture) end |
Instance Method Details
#call(argv, stdin: nil, timeout: 30) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hermetic/transport/subprocess.rb', line 19 def call(argv, stdin: nil, timeout: 30) unless argv.is_a?(Array) && !argv.empty? && argv.all?(String) raise ConfigError, "argv must be a non-empty Array of Strings, got #{argv.inspect}" end out, err, status, timed_out = @capture.call(argv, stdin: stdin, timeout: timeout) return [ out, err, status, false ] unless timed_out [ "", "hermetic: command timed out after #{timeout}s", TIMEOUT_EXIT, true ] end |