Why prevent a file from opening as controlling terminal (with O_NOCTTY)?

c, linux

Solution

Having a controlling tty means there are certain conditions where specific signals might be sent to your program in response to things happening on the tty/window where your program is running. If the program is intended to be a daemon, it's generally cleaner to make sure you don't have a controlling tty than it is to try to write code to handle all the extra conditions that you don't really care about to begin with...

Problem

The purpose of O_NOCTTY is documented as : O_NOCTTY - prevent the OS from assigning the opened file as the process's controlling terminal when opening a TTY device file Can somebody explain the intention of preventing a file as opening a controlling terminal ?

Original source