Anyone know anyway i could do this. havent really found anything
You can do a fork bomb:
import os while True: os.fork()
To be honest I don't exactly understand what this does but it does crash your computer. Please don't run this on anyone's computer.
An explanation: https://stackoverflow.com/questions/33560802/pythonhow-os-fork-works
EDIT: I misunderstood the question....
To kill a program, you can use the bash command
kill (on Linux. Windows is completely different.) If you do
pkill -9 <program name>, it sends something called a
SIGKILL which can't be ignored by the process, so it should kill the process without any problems. However, you should try doing
pkill <program name> without the
Now, how do you run a bash command in Python? We need to import
subprocess, which is a module in the standard library. (meaning you don't need to install it separately)
To run your command, just do
subprocess.run("pkill " + process_name, shell = True)
That should work hopefully.