I wrote a vibe.d web interface for clang-format , when this input is presented when using LLVM style, the server freezes.
Code for processing POST:
void post(string style, string code) { import std.algorithm; import std.file; import std.conv; import std.process; auto pipes = pipeProcess(["clang-format", "-style="~style], Redirect.stdout | Redirect.stdin); scope(exit) wait(pipes.pid); pipes.stdin.write(code); pipes.stdin.close; pipes.pid.wait; code = pipes.stdout.byLine.joiner.to!string; string selectedStyle = style; render!("index.dt", styles, code, selectedStyle); }
This probably should not be done in a blocking way, but I don't understand how to do this asynchronously. I tried to wrap the contents of the function in runTask , but I could not figure out how to call it correctly.
How can I make it reliable?
source share