diff --git a/linenoise.c b/linenoise.c index cfe51e76..bad0f3f8 100644 --- a/linenoise.c +++ b/linenoise.c @@ -1194,7 +1194,7 @@ int linenoiseHistorySave(const char *filename) { fp = fopen(filename,"w"); umask(old_umask); if (fp == NULL) return -1; - chmod(filename,S_IRUSR|S_IWUSR); + fchmod(fp,S_IRUSR|S_IWUSR); for (j = 0; j < history_len; j++) fprintf(fp,"%s\n",history[j]); fclose(fp);