fix(unix): do not starve subprocess that writes on stderr

This commit is contained in:
Simon Cruanes 2020-06-06 14:38:41 -04:00
parent 54099f10d5
commit e92b4bcef4
2 changed files with 9 additions and 4 deletions

View file

@ -97,10 +97,16 @@ let call_full_inner ?(bufsize=2048) ?(stdin=`Str "") ?(env=Unix.environment()) ~
end;
close_out ic;
(* read out and err *)
let out = read_all ~size:bufsize oc in
let out = ref "" in
let t_out =
Thread.create
(fun oc ->
out := read_all ~size:bufsize oc)
oc in
let err = read_all ~size:bufsize errc in
Thread.join t_out;
let status = Unix.close_process_full (oc, ic, errc) in
f (out,err,status)
f (!out,err,status)
)
let call_full ?bufsize ?stdin ?env cmd =

View file

@ -6,5 +6,4 @@
(optional)
(flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string)
(ocamlopt_flags :standard (:include ../flambda.flags))
(libraries unix)
)
(libraries unix threads))