When killing a process with kill -9 $PID &>/dev/null in a script, a message is still printed to the terminal after the next command terminates. How do you stop this behaviour?
For example
while true; do
/usr/bin/dostuff -a -b -c
PID=$(pidof -o %PPID /usr/bin/dostuff)
sleep 1;
kill -KILL $PID &>/dev/null
echo "hello"
done
will print something like
hello
./my-cript.sh: line 12: 7134 Killed
/usr/bin/dostuff -a -b -c
When I only want it to print "hello"
EDIT: The clean solution is to either run the program in a subshell, or disown it.
#SOLUTION
while true; do
/usr/bin/dostuff -a -b -c &
disown
PID=$!
sleep 1;
kill -KILL $PID &>/dev/null
echo "hello"
done