This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]