From 76337de2fe9938006ecc7088c91aa4335b49f5ec Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 10 Apr 2025 15:00:55 +0900 Subject: [PATCH] Attempt to fix write bug by setting pipe blocking Attempts to fix https://github.com/Stephen-Seo/SimpleArchiver/issues/6 . --- src/archiver.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/archiver.c b/src/archiver.c index aee8a5a..68c0a5c 100644 --- a/src/archiver.c +++ b/src/archiver.c @@ -6734,6 +6734,14 @@ SDArchiverStateRetStruct simple_archiver_write_v4v5( } } + const int existing_pipe_flags = fcntl(pipe_into_write, F_GETFL); + const int existing_pipe_flags_blocking = + existing_pipe_flags & ~O_NONBLOCK; + if (fcntl(pipe_into_write, F_SETFL, existing_pipe_flags_blocking) == -1) { + fprintf(stderr, + "ERROR: Unable to remove non-blocking on into-write-pipe!\n"); + return SDA_RET_STRUCT(SDAS_COMPRESSION_ERROR); + } simple_archiver_internal_cleanup_int_fd(&pipe_into_write); // Finish writing. -- 2.49.0