Hacker News new | ask | show | jobs
by jwilk 1270 days ago
You can redirect stdin, but that doesn't disassociate the process from the controlling terminal:

  $ tty
  /dev/pts/1

  $ tty < /dev/null
  not a tty

  $ ps -q $$ -o tty= < /dev/null
  pts/1
The other file descriptors referring to the terminal don't matter either:

  $ sh -c 'pid=$$; tty=$(ps -q $pid -o tty=); echo "$tty" > /dev/tty' <&- >&- 2>&-
  pts/1