eio icon indicating copy to clipboard operation
eio copied to clipboard

Redirecting stderr to stdout

Open patricoferris opened this issue 1 year ago • 3 comments

I don't think we have a convenient way to do this without having to essentially recreate most of what is internal to Eio_unix.Process ? Is it reasonable to expect the following program to work?

open Eio

let () =
  Eio_main.run @@ fun env ->
  let proc = Eio.Stdenv.process_mgr env in
  let out = Eio.Process.parse_out proc ~stderr:env#stdout Buf_read.take_all [ "sh"; "-c"; "echo out1; echo >&2 out2; echo out3" ] in
  Eio.traceln "%s" out

I'm guessing it doesn't because internally stdout is remapped to a pipe and so we really want to say remap stderr to whatever stdout is now mapped to i.e. here: https://github.com/ocaml-multicore/eio/blob/dbcbd6488267bf1551c6b2401327f1c1ffaca3b5/lib_eio/unix/process.ml#L90-L96

But maybe I'm missing something.

patricoferris avatar Jun 05 '23 10:06 patricoferris