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

src/archiver.c

index 026e813ff6dfaf1fbf99b22c6336a23e3c3ccb09..bde931797a7c805f16cadd757e921fbbe29c7c5d 100644 (file)
@@ -6627,6 +6627,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.