Hello, There was a question stackoverflow regarding something very similar : <https://stackoverflow.com/questions/64026829/how-to-temporarily-capture-stdout/64032172#64032172>
The main take is that you need take stdout using posix function dup / dup2 if you want to be able to safely capture stdout and restore it.
