linux-user/elfload: Truncate core file on open

While we usually create a new corefile, truncate otherwise.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2024-02-26 17:07:38 -10:00
parent 106f8da664
commit e0add9a835

View 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) {