I have a shell script which in turn starts a python script. Python script further creates a process pool and does its stuff.
conda activate app_env
... some other shell commands ...
clean() {
# make sure all process created by python and python itself
# gets killed
}
trap clean SIGINT
python start_server.py
When someone manually tries to exit the script using ctrl+c
, I need to make sure that all the processes started by python get killed. Is there a way where I could all the child process started by the shell script in one go or may be step by step?
Right now, I listen for the ctrl+c
signal and then execute the cleaning function. After I have detected the ctrl+c
signal, how do I kill the processes started by python
i.e started by this shell script