so I have these functions, a part of a larger bash script. And the issue is that my wait step is throwing error 
pid 1 is not a child of this shell
function getJobId(){
  local result=$(echo "$1" | sed s/^[^0-9]*// | sed s/[^0-9].*$//)
  echo $result
}
function deploy(){
  echo "Building now"
  nohup docker-compose build $1 &> logs/$2.txt &
  lastJob=$(getJobId $(jobs %%))
  echo "lastjob is --- $lastJob"
  jobsList="$jobsList $lastJob"
}
for job in $jobsList
do
  wait $job
  exit_code=$?
  if [[ "$exit_code" != 0 ]]; then
    handleError
  fi
done
I checked the lastJob, and it contains a valid value. The bash script is executed as root from the terminal of a GCP ubuntu machine.
 
    