Re: [PATCH 5/7] Close file handle of empty history file

Christian Biesinger
2020-05-26T16:38:06Z

On Mon, May 25, 2020 at 1:58 PM Hannes Domani via Gdb-patches
<gdb-patches@sourceware.org> wrote:
>
> Happened while trying to reproduce a gdb.base/gdbinit-history.exp failure:
> warning: Could not rename C:/gdb/build64/gdb-git/gdb/testsuite/outputs/gdb.base/gdbinit-history/gdbinit-history.gdb_history to C:/gdb/build64/gdb-git/gdb/testsuite/outputs/gdb.base/gdbinit-history/gdbinit-history.gdb_history-gdb5228~: Permission denied
>
> I had an empty gdbinit-history.gdb_history-gdb5228~ file, and the file
> handle was not closed on startup, so it couldn't rename it at the end
> when trying to write a new one.

Readline has an upstream repository, please send the patch to them as
well at bug-readline@gnu.org.
https://tiswww.case.edu/php/chet/readline/rltop.html

Also add the change to readline/README per the instructions in there.
Not sure if ChangeLog needs/should be updated.

Christian

>
> readline/readline/ChangeLog:
>
> 2020-05-25 Hannes Domani <ssbssa@yahoo.de>
>
> * histfile.c (read_history_range): Close file handle.
> ---
> readline/readline/histfile.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/readline/readline/histfile.c b/readline/readline/histfile.c
> index dc64bde1c5..a8a92aa360 100644
> --- a/readline/readline/histfile.c
> +++ b/readline/readline/histfile.c
> @@ -305,6 +305,7 @@ read_history_range (const char *filename, int from, int to)
> if (file_size == 0)
> {
> free (input);
> + close (file);
> return 0; /* don't waste time if we don't have to */
> }
>
> --
> 2.26.2
>