Does keyboard input always go through a controlling terminal?
3
votes
1
answer
2833
views
Am I right that all input typed from the keyboard goes through a _controlling terminal_? That means that if a program is run without a controlling terminal, it won't be able to receive any user input. Is that right for every kind of program in Linux?
**UPDATE #1**: To clarify the question, my pager module for Python [crashes when stdin is redirected](https://bitbucket.org/techtonik/python-pager/issues/7/33-piping-input-doesnt-work-for-linux) :
$ ./pager.py
page(sys.stdin)
File "pager.py", line 375, in page
if pagecallback(pagenum) == False:
File "pager.py", line 319, in prompt
if getch() in [ESC_, CTRL_C_, 'q', 'Q']:
File "pager.py", line 222, in _getch_unix
old_settings = termios.tcgetattr(fd)
termios.error: (25, 'Inappropriate ioctl for device')
This is because I try to get descriptor to setup keyboard input as
fd = sys.stdin.fileno()
. When stdin
is redirected, its file descriptor no longer associated with any keyboard input, so attempt to setup it fails with input-output control
error.
I was told to get this controlling terminal
instead, but I had no idea where does it come from. I understood that it is some kind of channel to send signals from user to running processes, but at the same time it is possible to run processes without it.
So the question is - should I always read my keyboard input from controlling terminal
? And what happens if the pager process is run without it? Will keyboard input still matter to user? Should I care to get it from some other source?
Asked by anatoly techtonik
(2784 rep)
Mar 13, 2017, 07:23 AM
Last activity: Mar 21, 2017, 09:37 AM
Last activity: Mar 21, 2017, 09:37 AM