0

In my program I call a function that sometimes write to stdout some "notices" or "warnings".

Since I don't need that output and furthermore it mixes with the output my program produces I want to get rid of the "notices" from the verbose function.

The function is not part of my code. Instead it's part of a OS' dynamic library (I can't edit the function).

Is there there any way to suppress output from that function?

Or can I suppress output before the function call and restore it after the call?

Paolo
  • 15,233
  • 27
  • 70
  • 91
  • 1
    You can redirect `stdout` to `/dev/null` before you call the function, then restore it after the function returns. – Barmar Sep 24 '19 at 17:47
  • 2
    Are you sure it's writing to stdout, not stderr? – Barmar Sep 24 '19 at 17:47
  • 1
    Have you looked at the documentation of the function to see if there is already a solution built into the function? – Christian Gibbons Sep 24 '19 at 17:48
  • @Barmar yes, I'm sure the function writes to `stdout`. Could you give me a hint on how redirect `stdout` inside the program? – Paolo Sep 24 '19 at 17:49

0 Answers0