Actually in c shell 'echo $?varName' will give existence of environmental variable .
But popen using bash shell to execute commands .
And I found that there isn't a way to differentiate 'variable having value nothing ' to 'undefined variable' , both are same in bash (please let me know if any thing wrong).
Currently I am using getenv to check variable existence and it's working fine.