Re: [PATCH] Append to input history file instead of overwriting it

Eli Zaretskii
2014-12-10T17:17:40Z

> Date: Wed, 10 Dec 2014 16:54:13 +0000
> From: Pedro Alves <palves@redhat.com>
> CC: gdb-patches@sourceware.org
>
> Is it that hard to do though? How about temporarily renaming the
> history file to something that includes gdb's PID (and would not a
> file name a user would use in practice) while we append
> to it, and then (atomically) rename it back? Something like:
>
> #1 - move $HISTFILE -> $HISTFILE-gdb$PID~
> #2 - write/append history to $HISTFILE-gdb$PID~
> #3 - move $HISTFILE-gdb$PID~ -> $HISTFILE

You cannot portably rename a file someone writes to, unless you are
willing to limit this to Posix filesystems.