esc

Externally Scriptable Editor

git clone git://mccd.space/esc

commit 46f5c673e7eba7f5bec9a4f7c55ef753607282dc
parent 60f3c809db781e20b5e3cd4f11b2b0c54c4fef36
Author: Marc Coquand <marc@coquand.email>
Date:   Mon, 23 Feb 2026 16:15:28 +0100

*

Diffstat:
Mfuse_ipc.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/fuse_ipc.c b/fuse_ipc.c
@@ -188,6 +188,10 @@ static int op_open(const char *path, struct fuse_file_info *fi)
 		return 0;
 	}
 
+	/* Read-only open on a writable file: no write buffer needed */
+	if ((fi->flags & O_ACCMODE) == O_RDONLY)
+		return 0;
+
 	WriteBuffer *wb = calloc(1, sizeof(WriteBuffer));
 	if (!wb)
 		return -ENOMEM;
@@ -453,9 +457,12 @@ void fuse_ipc_stop(FuseIPC *ipc)
 {
 	if (!ipc)
 		return;
-	fuse_exit(ipc->fuse);
-	SDL_WaitThread(ipc->thread, NULL);
+	/* Unmount first: tears down the kernel-side channel, causing
+	 * fuse_loop's blocking read to return an error and the thread
+	 * to exit.  Calling fuse_exit alone is not enough because
+	 * fuse_loop only checks the exit flag after receiving a request. */
 	fuse_unmount(ipc->mountpoint, ipc->chan);
+	SDL_WaitThread(ipc->thread, NULL);
 	fuse_destroy(ipc->fuse);
 	rmdir(ipc->mountpoint);
 	free(ipc->ctx);