I have this script.sh where I pass the path to the binaries, all apps run in the background:
./script.sh path/to/app_1 path/to/app_2 ... path/to/app_n
Here is the script:
#!/bin/bash
for app in "$@"
do
$app &
done
All my apps are running as I expected. Some of them are just console applications without windows, but some apps have interface and I can close the window app.
I can get pid of the app, something like this:
pgrep "${app##*/}"
How to kill all apps by pids that I passed through script.bash as arguments? When I close one of the windows it should kill all known running apps.
while true
infinite loop that either checks if the values are different, or if the pid array length is lower than expected (whichever works best), and when that is no longer true you sendkill
to every pid in the array and exit the script.