Controlling terminals

Provided that it is a session leader, a process without a controlling tty acquires a controlling terminal on the first open() to a tty, unless NOCTTY is specified in the open() call.