I have written a POC .This code works fine in Linux but not in Solaris. I am using Solaris 10
#!/bin/sh
echo inside parent
echo executing child in the background
./remove deepti & # executing dummy command to make sure that background process fails
childpid=$!
i=0
while [ `ps -p $childpid >/dev/null; echo $?` = 0 ]; do
sleep 5
i=`expr $i + 1`
if [ $i -gt 3 ]; then
echo wait exceeded
ps -p $childpid >/dev/null
exit $?
fi
done
wait
$childpid
exit $?
I expect that Wait shall return me the exit status of background command . exit status should be 127 . However I get exit status as 0.