check for cwd() failures
use getcwd() instead of cwd()

getcwd() does a C library call to getcwd and avoid making a new process
for `/bin/pwd` (that probably does the same thing).
Merge pull request #49 from nnutter/above

check for cwd() failures