Capture the stdout output of a ccall?

I’m ccalling a function in a shared lib which writes something to stdout (i.e. it appears it the terminal). Is it possible to capture this text output? Among other things, I tried

mktemp() do path, io
    redirect_stdout(io) do
    s = read(path, String)

but this only produces s == "test1\ntest2\n" .

Any ideas how to capture the stdout output triggered by the ccall as well?

Thanks in advance!

Maybe it prints to stderr?

No, it doesn’t. Replacing redirect_stdout with redirect_stderr just gives s == "".

Did you try with Julia 1.7? I think I have seen it capture more things from standard streams.

I just tried with a simple example and it did capture it properly, so not sure why it doesn’t work for you.