Fix chdir to support relative paths.