3

C uses abort to terminate the process by raising a SIGABRT signal. What is the equivalent abort in Python? Thanks.

wad
  • 2,491
  • 3
  • 14
  • 16

1 Answers1

0

Try this:

import sys
sys.exit()

You can also give some text as a parameter to print the error message.

sys.exit("This is the error")
Arvindsinc2
  • 716
  • 7
  • 18
  • So, sys.exit is going to terminate the process, rather than shut down the whole python program, right? – wad Apr 09 '17 at 12:29
  • @wad: What distinction are you trying to make there? – Eric Apr 09 '17 at 12:32
  • Since exit() only raises an exception, it will only exit the process when called from the main thread, and the exception is not intercepted. – Arvindsinc2 Apr 09 '17 at 12:33
  • 1
    No, this is normal exit. `os.abort()` calls C `abort`. Why is this question marked as duplicate when the linked questions do not aswer? – vaclav.blazek May 21 '19 at 13:01