change_dir initialized as NULL, and call chdir when change_dir is not NULL