Skip to content

Commit 513d956

Browse files
committed
rustdoc: Run pandoc in a way that won't deadlock waiting for IO
1 parent dc0b9f4 commit 513d956

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/rustdoc/markdown_writer.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,19 @@ fn pandoc_writer(
101101
os::close(pipe_err.out);
102102
os::close(pipe_in.out);
103103

104-
let stdout = result::get(task::try {||
105-
readclose(pipe_out.in)
106-
});
107-
let stderr = result::get(task::try {||
108-
readclose(pipe_err.in)
109-
});
104+
let stdout_po = comm::port();
105+
let stdout_ch = comm::chan(stdout_po);
106+
task::spawn_sched(task::single_threaded) {||
107+
comm::send(stdout_ch, readclose(pipe_out.in));
108+
}
109+
let stdout = comm::recv(stdout_po);
110+
111+
let stderr_po = comm::port();
112+
let stderr_ch = comm::chan(stderr_po);
113+
task::spawn_sched(task::single_threaded) {||
114+
comm::send(stderr_ch, readclose(pipe_err.in));
115+
}
116+
let stderr = comm::recv(stderr_po);
110117

111118
let status = run::waitpid(pid);
112119
#debug("pandoc result: %i", status);

0 commit comments

Comments
 (0)