`/dev/tty` is a reference to the controlling terminal for a process. But in order for it to have a controlling terminal, a real terminal has to be opened and been assigned to the process.
Perhaps instead of opening /dev/tty you should open /dev/tty0 or /dev/console or /dev/tty1
If a process does not have a controlling terminal, and it opens a tty or pty, if nothing else is using that tty as a controlling terminal already, then the process will be assigned that tty as a controlling terminal. It is also possible to open a tty and assign it as the controlling terminal with an IOCTL if the conditions are correct.
However /dev/tty is not a real tty, so these conditions don't apply to it.