use fchdir when available
Merge pull request #1 from ap/fchdir

Use fchdir when available