commit e3ef7787562645251773212b4f7d2ee3805bb79b
parent 806e8e439f3e6fe416bfb9acc972b8ba1c7d0a42
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 14 Jul 2021 09:53:18 +0200
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>
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -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");