The file /dev/tty is a character file with major number 5 and minor
number 0, usually of mode 0666 and owner.group root.tty. It is a synonym for
the controlling terminal of a process, if any.
In addition to the ioctl() requests supported by the device that
tty refers to, the ioctl() request TIOCNOTTY is
Detach the current process from its controlling terminal.
If the process is the session leader, then SIGHUP and SIGCONT signals are sent
to the foreground process group and all processes in the current session lose
their controlling tty.
This ioctl() call only works on file descriptors connected to
/dev/tty. It is used by daemon processes when they are invoked by a
user at a terminal. The process attempts to open /dev/tty. If the open
succeeds, it detaches itself from the terminal by using TIOCNOTTY,
while if the open fails, it is obviously not attached to a terminal and does
not need to detach itself.