Add a note about why we play with file descriptors

This commit is contained in:
Kovid Goyal 2023-01-26 21:50:10 +05:30
parent f8991ce3c8
commit 5338fcdc1e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -495,6 +495,8 @@ def main(args: List[str]) -> Response:
loop.loop(phandler) loop.loop(phandler)
return {'items': items, 'response': phandler.response} return {'items': items, 'response': phandler.response}
# we do this file descriptor dance to get readline to work even when STDOUT
# is redirected
orig_stdout = os.dup(sys.stdout.fileno()) orig_stdout = os.dup(sys.stdout.fileno())
try: try:
with open(os.ctermid(), 'r') as tty: with open(os.ctermid(), 'r') as tty: