mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 03:35:30 -05:00
fix(unix): do not starve subprocess that writes on stderr
This commit is contained in:
parent
54099f10d5
commit
e92b4bcef4
2 changed files with 9 additions and 4 deletions
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue