Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/childprocess/process_spawn_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def launch_process
options[:out] = io.stdout ? io.stdout.fileno : File::NULL
options[:err] = io.stderr ? io.stderr.fileno : File::NULL

reader = writer = nil
if duplex?
reader, writer = ::IO.pipe
options[:in] = reader.fileno
Expand Down Expand Up @@ -86,6 +87,11 @@ def launch_process
@pid = ::Process.spawn(environment, *args, options)
rescue SystemCallError => e
raise LaunchError, e.message
ensure
unless @pid
reader&.close
writer&.close
end
end

if duplex?
Expand Down