    exit 1
  fi

  # before starting current job, remove evidence of failed job.
  if [ -e "$lockfile_failed_fp" ] ; then
    rm "$lockfile_failed_fp"
  fi

  # automatically remove the lockfile when finished, whether fail or success
  function remove_lockfile() {
    rm $lockfile_fp
  }
  function trap_success() {
    if [ ! -e "$lockfile_failed_fp" ] ; then