How to capture stdout and stderr in <1.1?

The following works in 1.1 but fails in earlier versions.
What would be the right/best way to capture both stdout and stderr in <1.1?

stdout_buf = IOBuffer()
stderr_buf = IOBuffer()
run(pipeline(ignorestatus(cmd), stdout=stdout_buf, stderr=stderr_buf))

I appreciate that 1.1 has IOBuffer() and spawn interaction changes, but for reference, this is the error in 1.0.3 on macos:

ERROR: MethodError: no method matching rawhandle(::Base.GenericIOBuffer{Array{UInt8,1}})
1 Like

Self-answering given that this seems to work:

out = Pipe()
err = Pipe()
p = Base.open(pipeline(ignorestatus(cmd), stdout=out, stderr=err))
close(out.in); close(err.in)
err_s = readlines(err)
out_s = readlines(out)
1 Like