C program output should go to console, but should not be redirectable C program output should go to console, but should not be redirectable linux linux

C program output should go to console, but should not be redirectable


You can try opening /dev/tty, but it doesn't necessarily exist, if your program run from the environment with no tty.


Maybe isatty or /dev/tty could be useful to you.