]> git.seodisparate.com/gitweb - 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, 25 Apr 2025 08:25:23 +0000 (17:25 +0900)
Attempts to fix https://github.com/Stephen-Seo/SimpleArchiver/issues/6 .

src/archiver.c

index aee8a5ad040638658336527dc0624c218940a5e5..68c0a5c7e609923bdc032914d0f5d7e410ea0600 100644 (file)
@@ -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.