What could be causing my previously functioning Ctrl c shortcut to no longer work in VSC?

37 Views Asked by At

VSC ignores Ctrl c

My VSC ignores Ctrl c, it used to stop the process and send a sigint but it no longer works

this is what my code looks like:


import signal
import sys
import time



def signal_handler(sig, frame):
    print("You pressed Ctrl+C!")
    sys.exit(0)

if __name__ == "__main__":
    signal.signal(signal.SIGINT, signal_handler)
    print("Press Ctrl+C")
    while True:
        time.sleep(1)

And the output is :

python test.py
Press Ctrl+C
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C

The crtl c is being seen but vsc does nothing with it

Help:About is :

Version: 1.78.2 (Universal)
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:44:45.204Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin x64 17.7.0
Sandboxed: No
1

There are 1 best solutions below

3
Raqun Bob On

pause function call was unsecured or something like this that they got rid of it after some version. Use the below for the same result and read the time library.

import signal
import sys
import time


def signal_handler(sig, frame):
    print("You pressed Ctrl+C!")
    sys.exit(0)

if __name__ == "__main__":
    signal.signal(signal.SIGINT, signal_handler)
    print("Press Ctrl+C")
    while True:
        time.sleep(1)