#!/bin/bash if [ $# -eq 0 ]; then echo "Usage: pwait " echo "Waits until PID has terminated, then continues." echo "Example: pwait 123 && echo DONE" exit 1 fi for pid in "$@"; do while [ -e /proc/$pid ]; do sleep 0.1 done done