I’m starting a number of screens in a bash script, then running django’s runserver command in each of them. I’d like to be able to programmatically stop them all as well, which requires me to send Control+c to runserver.
How can I send these keystrokes from my bash script?
Ctrl+C sends a
SIGINTsignal.kill -INT <pid>sends aSIGINTsignal too:Assuming
888is your process ID.Note that
kill 888sends aSIGTERMsignal, which is slightly different, but will also ask for the program to stop. So if you know what you are doing (no handler bound toSIGINTin the program), a simplekillis enough.To get the PID of the last command launched in your script, use
$!: