Skip to content

Commit db97f51

Browse files
committed
Fix fork behavior in yard server --fork
1 parent 49d605c commit db97f51

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: lib/yard/server/commands/library_command.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ def call_without_fork(request)
9494
end
9595

9696
def call_with_fork(request, &block)
97-
reader, writer = IO.pipe
97+
IO.pipe(:binmode => true) do |reader, writer|
98+
fork do
99+
log.debug "[pid=#{Process.pid}] fork serving: #{request.path}"
100+
reader.close
101+
writer.print(Marshal.dump(call_without_fork(request, &block)))
102+
end
98103

99-
fork do
100-
log.debug "[pid=#{Process.pid}] fork serving: #{request.path}"
101-
reader.close
102-
writer.print(Marshal.dump(call_without_fork(request, &block)))
104+
writer.close
105+
Marshal.load(reader.read)
103106
end
104-
105-
writer.close
106-
Marshal.load(reader.read)
107107
end
108108

109109
def can_fork?

0 commit comments

Comments
 (0)