From 519c05d9c9b6da12b951b7cdbce263650393fce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 26 May 2020 03:51:22 +0200 Subject: [PATCH] Clean up named pipes --- github-fast-env/github-fast-envd.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/github-fast-env/github-fast-envd.rb b/github-fast-env/github-fast-envd.rb index a0d1718..8bfa8eb 100644 --- a/github-fast-env/github-fast-envd.rb +++ b/github-fast-env/github-fast-envd.rb @@ -126,6 +126,20 @@ def set_up_named_pipes(control_socket, connection_id) $stderr.reopen(stderr) end +def clean_up_named_pipes(control_socket, connection_id) + pipe_base_path = "/#{$run_base_path}/github-fast-envd.#{connection_id}" + + if File.exist?("#{pipe_base_path}.stdin") + File.delete("#{pipe_base_path}.stdin") + end + if File.exist?("#{pipe_base_path}.stdout") + File.delete("#{pipe_base_path}.stdout") + end + if File.exist?("#{pipe_base_path}.stderr") + File.delete("#{pipe_base_path}.stderr") + end +end + def set_up_pseudoterminal(control_socket, pseudoterminal_path) pseudoterminal_io = File.open(pseudoterminal_path, File::RDWR | File::NOCTTY) @@ -235,6 +249,10 @@ while true end control_socket.close + if mode == "named-pipes" + clean_up_named_pipes(control_socket, connection_id) + end + $original_stderr.puts " finished handling request (#{process_id})" Kernel.exit!