However, I still don't understand how does a program know it's connected to a terminal rather than some pipes.
However, I still don't understand how does a program know it's connected to a terminal rather than some pipes.