]> git.seodisparate.com - SimpleArchiver/commitdiff
Attempt to fix write bug by setting pipe blocking archive_create_fail_attempt_fix
authorStephen Seo <seo.disparate@gmail.com>
Thu, 10 Apr 2025 06:00:55 +0000 (15:00 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 18 Apr 2025 08:35:11 +0000 (17:35 +0900)
Attempts to fix https://github.com/Stephen-Seo/SimpleArchiver/issues/6 .

src/archiver.c

index 2cb24525ca1e136131d5c202af1b6c5b9893b0b4..418e5d93e4d67059d4be42022652d9b5c6c98be0 100644 (file)
@@ -6658,6 +6658,14 @@ SDArchiverStateRetStruct simple_archiver_write_v4(
         }
       }
 
+      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.