#!/bin/bash

if [ "$#" != "1" ]
then
  echo "Usage $0 processname"
  exit
fi

while true
do
  PID="$(pgrep -d',' $1)"
  if [ -z "$PID" ]
  then
    clear
    sleep 0.1
  else
    top -p "$PID" -n1
    RET=$?
    if [ $RET -eq "130" ]
    then
      break
    fi
  fi
done

echo "Done"
