From f6e8078c4698d371359ff8827a017535e421496c Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 11 Jun 2021 21:09:46 -0400 Subject: Exclusively lock save file Prevents two instances of catgirl from using the same save file and clobbering each other's data. --- ui.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui.c b/ui.c index 22b098e..2beba88 100644 --- a/ui.c +++ b/ui.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1183,6 +1184,11 @@ void uiLoad(const char *name) { if (!saveFile) exit(EX_CANTCREAT); rewind(saveFile); + int error = flock(fileno(saveFile), LOCK_EX | LOCK_NB); + if (error && errno == EWOULDBLOCK) { + errx(EX_CANTCREAT, "%s: save file in use", name); + } + time_t signature; fread(&signature, sizeof(signature), 1, saveFile); if (ferror(saveFile)) err(EX_IOERR, "fread"); -- cgit 1.4.1 a> refs log tree commit diff
path: root/bin (unfollow)
Commit message (Expand)Author
2021-09-15Set bot mode on downgradeJune McEnroe
2021-09-15Enter capsicum in downgradeJune McEnroe
2021-09-15Factor out common parts of downgrade messagesJune McEnroe
2021-09-14Add downgrade IRC botJune McEnroe
2021-09-14Sort by title if authors matchJune McEnroe
2021-09-13Swap-remove tags as they're foundJune McEnroe
2021-09-12Replace htagml regex with strncmpJune McEnroe
2021-09-11Also defer printing comment for lone close-parensJune McEnroe
2021-09-10Publish "git-comment"June McEnroe
2021-09-10Add git comment --pretty optionJune McEnroe
2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe
2021-09-08Up default min-repeat to 30 linesJune McEnroe
2021-09-08Handle dirty lines in git-commentJune McEnroe
2021-09-08Document and install git-commentJune McEnroe
2021-09-08Add repeat and all options to git-commentJune McEnroe
2021-09-08Add group threshold to git-commentJune McEnroe