How To Send Control C To Mac Terminal Using Python?
I have a python script that needs to send control C to the mac terminal. I've tried sending the plain text '^C' but I get back that the terminal does not recognize the command. (Th
Solution 1:
You can explicitly send the SIGINT signal to the process if you can get its PID using os.kill
.
os.kill(pid, signal.SIGINT)
This will require you to instrument your script to grab the process PID, but it's the best way to emulate the "ctrl-c" behavior.
Post a Comment for "How To Send Control C To Mac Terminal Using Python?"