Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to Kill Terminal in VSCode using a python code?

I understand that using import os os._exit(0) will pause the code, but I would like to kill terminal completely, as if I were clicking on the button shaped like a trash can.

Is there any way to do this so I can put it inside my python code?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It’s hacky and won’t work inside a Python subprocess, but it works in a basic sense:

import os
ppid = os.getppid()
os.system("taskkill /f /pid " + str(ppid))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading