#!/bin/zsh while true do ./thread2 if [[ $? != 0 ]] then break fi done echo "there was a problem"