Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 191220) +++ main/asterisk.c (working copy) @@ -3435,6 +3435,20 @@ ast_log(LOG_WARNING, "Unable to set the process for core dumps after changing to a non-root user. %s\n", strerror(errno)); } } + + if (!ast_opt_no_fork && !ast_opt_dump_core) { + if (chdir("/")) { + ast_log(LOG_ERROR, "Unable to chdir(\"/\") ?!! %s\n", strerror(errno)); + } + } else { + char dir[PATH_MAX]; + if (!getcwd(dir, sizeof(dir)) || eaccess(dir, R_OK | X_OK | F_OK)) { + ast_log(LOG_ERROR, "Unable to access the running directory (%s). Changing to '/' for compatibility.\n", strerror(errno)); + if (chdir("/")) { + ast_log(LOG_ERROR, "chdir() failed?!! %s\n", strerror(errno)); + } + } + } #endif ast_term_init();