Forward exit code

This commit is contained in:
Patrick Lühne 2020-05-24 07:11:38 +02:00
parent 2eb551da4c
commit cab2c74251
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 18 additions and 1 deletions

View File

@ -125,6 +125,8 @@ $control_socket.puts "ready"
read_ios = [$control_socket, $stdin, pipes["stdout"], pipes["stderr"]] read_ios = [$control_socket, $stdin, pipes["stdout"], pipes["stderr"]]
exit_code = "unknown"
while read_ios.include?($control_socket) or read_ios.include?(pipes["stdout"]) or read_ios.include?(pipes["stderr"]) while read_ios.include?($control_socket) or read_ios.include?(pipes["stdout"]) or read_ios.include?(pipes["stderr"])
log "trace", read_ios.inspect log "trace", read_ios.inspect
@ -150,6 +152,10 @@ while read_ios.include?($control_socket) or read_ios.include?(pipes["stdout"]) o
if command != "done" if command != "done"
log "error", "malformed response from github-fast-envd" log "error", "malformed response from github-fast-envd"
end end
if !arguments.empty?
exit_code = arguments[0]
end
else else
log "warn", "received input from unknown stream" log "warn", "received input from unknown stream"
end end
@ -161,3 +167,9 @@ while read_ios.include?($control_socket) or read_ios.include?(pipes["stdout"]) o
read_ios = read_ios.select {|x| not x.closed?} read_ios = read_ios.select {|x| not x.closed?}
end end
exit_code_is_numeric = Integer(exit_code) != nil rescue false
if exit_code_is_numeric
exit Integer(exit_code)
end

View File

@ -109,6 +109,8 @@ while true
original_stdout = $stdout.dup original_stdout = $stdout.dup
original_stderr = $stderr.dup original_stderr = $stderr.dup
exit_code = "unknown"
begin begin
stdin = open_pipe(connection_id, "stdin") stdin = open_pipe(connection_id, "stdin")
control_socket.puts "stdin #{stdin}" control_socket.puts "stdin #{stdin}"
@ -145,6 +147,9 @@ while true
begin begin
load script_path, true load script_path, true
rescue SystemExit => error
original_stderr.puts " exit code: #{error.status}"
exit_code = error.status
rescue => error rescue => error
$stdin = original_stdin $stdin = original_stdin
$stdout = original_stdout $stdout = original_stdout
@ -176,7 +181,7 @@ while true
end end
begin begin
control_socket.puts "done" control_socket.puts "done #{exit_code}"
rescue rescue
end end
control_socket.close control_socket.close