This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Append to input history file instead of overwriting it
- From: Pedro Alves <palves at redhat dot com>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: patrick at parcs dot ath dot cx, gdb-patches at sourceware dot org
- Date: Wed, 10 Dec 2014 17:23:33 +0000
- Subject: Re: [PATCH] Append to input history file instead of overwriting it
- Authentication-results: sourceware.org; auth=none
- References: <1417226462-11254-1-git-send-email-patrick at parcs dot ath dot cx> <54808956 dot 9070507 at redhat dot com> <alpine dot DEB dot 2 dot 11 dot 1412041913060 dot 2232 at idea> <54818CCE dot 5010701 at redhat dot com> <CA+C-WL8tCiJGO9FK8mxL+5hDh1afc6JeuBknUYeY+P8yCAF+dg at mail dot gmail dot com> <54887AB5 dot 3000101 at redhat dot com> <83a92vv37l dot fsf at gnu dot org>
On 12/10/2014 05:12 PM, Eli Zaretskii wrote:
>> 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.
The way I've proposed, no gdb would be actually writing directly
to $HISTFILE, only reading. Is it a problem still?
Not considering someone manually opening the file for writing, but
in that case the system that would fail the rename would fail the
write-in-place too.
Thanks,
Pedro Alves