Skip to content

Commit

Permalink
Fix fork behavior in yard server --fork
Browse files Browse the repository at this point in the history
  • Loading branch information
lsegal committed Apr 12, 2023
1 parent 49d605c commit db97f51
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/yard/server/commands/library_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ def call_without_fork(request)
end

def call_with_fork(request, &block)
reader, writer = IO.pipe
IO.pipe(:binmode => true) do |reader, writer|
fork do
log.debug "[pid=#{Process.pid}] fork serving: #{request.path}"
reader.close
writer.print(Marshal.dump(call_without_fork(request, &block)))
end

fork do
log.debug "[pid=#{Process.pid}] fork serving: #{request.path}"
reader.close
writer.print(Marshal.dump(call_without_fork(request, &block)))
writer.close
Marshal.load(reader.read)
end

writer.close
Marshal.load(reader.read)
end

def can_fork?
Expand Down

0 comments on commit db97f51

Please sign in to comment.