#!/bin/bash
#bootstrapper.sh
PIDD="$5"
while sleep 1; do kill -0 $PIDD || break; done
# Absolute path to this script. /home/user/bin/foo.sh
SCRIPT=$(readlink -f $0)
# Absolute path this script is in. /home/user/bin
SCRIPTPATH=`dirname $SCRIPT`
POSPAR1="$1" #-l
POSPAR2="$2" #location
POSPAR3="$3" #-d
POSPAR4="$4" #directory
cp -r -f $SCRIPTPATH/$4/* $2
rm -r -f $SCRIPTPATH/$4
The line:
while sleep 1; do kill -0 $PIDD || break; done
Is supposed to wait until the PID (stored in variable $PIDD) closes. It waits until it doesn't exist (the PID), but when it finally doesn't exist, it outputs: kill: 4: No such process. The rest of the script works as intended, but then the script doesn't te开发者_C百科rminate. Can I make the script terminate properly and not have that No such process be outputted?
Thanks again for all your help - I'm new to BASH/Linux.while sleep 1; do kill -0 $PIDD 2>/dev/null || break; done
or
while kill -0 $PIDD 2>/dev/null; do sleep 1; done
精彩评论