linux-user/elfload: Truncate core file on open
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 27 Feb 2024 03:07:38 +0000 (17:07 -1000)
committerRichard Henderson <richard.henderson@linaro.org>
Thu, 29 Feb 2024 18:48:02 +0000 (08:48 -1000)
While we usually create a new corefile, truncate otherwise.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
linux-user/elfload.c

index 877799e9c7b182009e940ec6b293cc60a718c3a7..16dd08a828ff94bbb3d33bcce4b17afaca31c8a7 100644 (file)
@@ -4652,7 +4652,7 @@ static int elf_core_dump(int signr, const CPUArchState *env)
 
     {
         g_autofree char *corefile = core_dump_filename(ts);
-        fd = open(corefile, O_WRONLY | O_CREAT,
+        fd = open(corefile, O_WRONLY | O_CREAT | O_TRUNC,
                   S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
     }
     if (fd < 0) {