I want my_custom_print() output to appear on console. But if the program’s stderror or stdout is redirected from shell, they should get redirected (as normal), but the output from my_custom_print() should get ignored.
Is it possible to write my_custom_print() satisfying above condition ? If possible, how?
You can try opening
/dev/tty, but it doesn’t necessarily exist, if your program run from the environment with no tty.