From 77540980f26e8b6d1635d912aa6b88781f9315b7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 7 Aug 2023 12:29:58 +0930 Subject: [PATCH] lightningd: use fsync not fdatasync. Apparently MacOS doesn't always have fdatasync, so use fsync. Even more importantly check whether it succeeds! Fixes: #6516 Signed-off-by: Rusty Russell --- lightningd/configs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lightningd/configs.c b/lightningd/configs.c index 65b325a221fa..564dde853b50 100644 --- a/lightningd/configs.c +++ b/lightningd/configs.c @@ -504,7 +504,8 @@ static bool configfile_replace_var(struct lightningd *ld, contents = tal_strjoin(tmpctx, take(lines), "\n", STR_TRAIL); if (!write_all(outfd, contents, strlen(contents))) fatal("Writing %s: %s", template, strerror(errno)); - fdatasync(outfd); + if (fsync(outfd) != 0) + fatal("Syncing %s: %s", template, strerror(errno)); if (rename(template, cv->file) != 0) fatal("Renaming %s over %s: %s",