files: when the buffer is nameless, include the PID in name of dump file

Make sure that when multiple nanos with nameless buffers die,
each of them tries saving those buffers to different files.

This addresses https://savannah.gnu.org/bugs/?60902.
Reported-by: Julian Rosen <julianrosen@gmail.com>
master
Benno Schulenberg 2021-07-14 09:53:18 +02:00
parent 806e8e439f
commit e3ef778756
1 changed files with 6 additions and 4 deletions

View File

@ -309,15 +309,17 @@ void do_exit(void)
statusbar(_("Cancelled"));
}
/* Save the current buffer under the given name (or under the name "nano"
/* Save the current buffer under the given name (or under "nano.<PID>"
* for a nameless buffer). If needed, the name is modified to be unique. */
void emergency_save(const char *plainname)
void emergency_save(char *plainname)
{
bool saved = FALSE;
char *targetname;
if (*plainname == '\0')
plainname = "nano";
if (*plainname == '\0') {
plainname = nrealloc(plainname, 28);
sprintf(plainname, "nano.%u", getpid());
}
targetname = get_next_filename(plainname, ".save");