Module: ClaudeSwarm::SystemUtils

Included in:
CLI, Orchestrator, WorktreeManager
Defined in:
lib/claude_swarm/system_utils.rb

Instance Method Summary collapse

Instance Method Details

#last_statusObject



24
25
26
# File 'lib/claude_swarm/system_utils.rb', line 24

def last_status
  $CHILD_STATUS
end

#system!(*args, **options) ⇒ Object



5
6
7
8
# File 'lib/claude_swarm/system_utils.rb', line 5

def system!(*args, **options)
  system(*args, **options)
  handle_command_failure(last_status, args)
end

#system_with_pid!(*args, **options) {|pid| ... } ⇒ Object

Yields:

  • (pid)


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/claude_swarm/system_utils.rb', line 10

def system_with_pid!(*args, **options)
  # Spawn the process - by default, inherits the parent's I/O
  pid = Process.spawn(*args, **options)

  # Yield the PID to the block if given
  yield(pid) if block_given?

  # Wait for the process to complete
  _, status = Process.wait2(pid)

  # Check the exit status
  handle_command_failure(status, args)
end