Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Patrick Palka <patrick@parcs.ath.cx>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Append to input history file instead of overwriting it
Date: Sat, 10 Jan 2015 15:48:00 -0000	[thread overview]
Message-ID: <CA+C-WL88pk1tnTHp1FS_LMhNXiypmWify75d2eJW4w+2aLjRTA@mail.gmail.com> (raw)
In-Reply-To: <83wq4u63wu.fsf@gnu.org>

On Sat, Jan 10, 2015 at 10:39 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Patrick Palka <patrick@parcs.ath.cx>
>> Cc: Patrick Palka <patrick@parcs.ath.cx>
>> Date: Sat, 10 Jan 2015 10:18:28 -0500
>>
>> +  local_history_filename = xstrprintf ("%s.%d", history_filename, getpid ());
>> +  old_chain = make_cleanup (xfree, local_history_filename);
>> +
>> +  ret = rename (history_filename, local_history_filename);
>> +  if (ret < 0)
>> +    {
>> +      /* If the rename failed then either the global history file never existed
>> +         in the first place or another GDB process is currently appending to it
>> +         (and has thus temporarily renamed it).  Since we can't distinguish
>> +         between these two cases, we have to conservatively assume the first
>> +         case and therefore must write out (not append) our known history to
>> +         our local history file and try to move it back anyway.  Otherwise a
>> +         global history file would never get created!  */
>> +      write_history (local_history_filename);
>> +    }
>> +  else
>> +    {
>> +      append_history (command_count, local_history_filename);
>> +      history_truncate_file (local_history_filename, history_max_entries);
>> +    }
>> +
>> +  ret = rename (local_history_filename, history_filename);
>> +  saved_errno = errno;
>> +  if (ret < 0)
>> +    warning (_("Could not rename %s to %s: error %d"),
>> +          local_history_filename, history_filename, saved_errno);
>> +
>> +  do_cleanups (old_chain);
>
> On Windows, a call to 'rename' fails if the destination already
> exists.  Does the logic here cope with that?

Hmm, the logic does not really cope with Windows' behavior here,
because the above warning should only get emitted for unexpected
failures.  So I suppose we should only emit the above warning if errno
!= EBUSY (perhaps only on Windows systems)?

>
> Thanks.


  reply	other threads:[~2015-01-10 15:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-29  2:01 Patrick Palka
2014-12-01 20:50 ` Sergio Durigan Junior
2014-12-04 16:18 ` Pedro Alves
2014-12-05  0:19   ` Patrick Palka
2014-12-05 10:45     ` Pedro Alves
2014-12-05 14:11       ` Patrick Palka
2014-12-10 16:54         ` Pedro Alves
2014-12-10 17:17           ` Eli Zaretskii
2014-12-10 17:23             ` Pedro Alves
2015-01-10 14:10           ` Patrick Palka
2015-01-10 15:16             ` Patrick Palka
2015-01-10 15:18               ` Patrick Palka
2015-01-10 15:39                 ` Eli Zaretskii
2015-01-10 15:48                   ` Patrick Palka [this message]
2015-01-10 16:03                     ` Eli Zaretskii
2015-01-10 16:18                       ` Patrick Palka
2015-01-10 16:41                         ` Eli Zaretskii
2015-01-10 18:17                           ` Patrick Palka
2015-01-10 18:46                             ` Patrick Palka
2015-01-12 19:05                               ` Pedro Alves
2015-01-12 22:56                                 ` Patrick Palka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+C-WL88pk1tnTHp1FS_LMhNXiypmWify75d2eJW4w+2aLjRTA@mail.gmail.com \
    --to=patrick@parcs.ath.cx \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox