There are different bash processes executing each line of code and `$?` isn't shared between the processes. You can work around this by making `judge` a bash function:
[root@xxx httpd]# type judge
judge is a function
judge ()
{
echo "last exit status is $?"
}
[root@xxx httpd]# ls -l / >/dev/null 2>&1; judge
last exit status is 0
[root@xxx httpd]# ls -l /doesntExist >/dev/null 2>&1; judge
last exit status is 2
[root@xxx httpd]#