```bash trap 'kill $(jobs -p)' EXIT; until myserver & wait; do echo "ldap proxy crashed with exit code $?. Respawning.." >&2 sleep 1 done ``` [Source](https://stackoverflow.com/a/697064)