0

When the user clicks the 'X' in the top right of the terminal running the program, I want there to be a confirmation that they really want to exit the program.

So far, the most that I've found is this but that only works with 'ctrl-c', not clicking the 'X'. I've also found

def on_exit(sig, fun=None):
    print("I can't prevent the exit")

win32api.SetConsoleCtrlHandler(on_exit, True)

Which would be perfect if it could prevent the exit.

nda
  • 541
  • 7
  • 18
  • @JohnHennig They already had that kind of choice, though, as long as their malware is not running in a terminal. – Imperishable Night Jun 26 '19 at 00:15
  • To OP: I think maybe the answer is "get a terminal with that feature". For example, the default terminal of Mac OS X asks "Do you want to terminate running processes in this window?" if there is a process running. – Imperishable Night Jun 26 '19 at 00:16
  • A terminal is just for input and output. It just so happens to have an `x` button to close it. – GeeTransit Jun 26 '19 at 00:55
  • @GeeTransit Thanks, I'll edit my comment to be correct. – nda Jun 26 '19 at 01:07
  • @ImperishableNight Thanks for the suggestion, but I am looking for a solution for Windows' command prompt. I'll update the question title to be more specific. – nda Jun 26 '19 at 01:08

0 Answers0