GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — gh-85984: Add _POSIX_VDISABLE from unistd.h to termios module. by 8vasu · Pull Request #114985 · python/cpython Conversation
|
|
In a previous PR in this series (#101832), I mentioned the idea of writing a Python library that mimics This is not a dependency of the main set of changes of this series in #101833, but since this idea was conceived while working on this issue and since this PR is so small, I did not create a separate issue for this. I have added a test script as a comment. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| #ifdef _POSIX_VDISABLE | ||
| {"_POSIX_VDISABLE", _POSIX_VDISABLE}, | ||
| #endif | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The following script uses termios._POSIX_VDISABLE to disable INTR. Then it calls stty(1) to check if INTR has successfully been disabled.
#!/usr/bin/python3 # Written and tested on Debian GNU/Linux 12 (bookworm) using stty (GNU coreutils) 9.1. import subprocess import termios def stty_intr_value(): out = subprocess.run(['stty', '-a'], stdout=subprocess.PIPE, text=True).stdout s = out.replace(";", " ") sub = "intr = " i = s.find(sub) + len(sub) return s[i:].split()[0] t = termios.tcgetattr(0) t[6][termios.VINTR] = bytes([termios._POSIX_VDISABLE]) termios.tcsetattr(0, termios.TCSANOW, t) assert stty_intr_value() == "<undef>" print("PASSED")
Hit Control-C after running running above script to see SIGINT not being sent.
Please run stty intr ^c to restore Control-C functionality.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@gpshead Thank you so much! I will make my stty-like library available soon and send you a link. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ython#114985) Signed-off-by: Soumendra Ganguly <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.