]> git.ipfire.org Git - pakfire.git/commitdiff
log stream: Correctly check for open file descriptors
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 14:53:30 +0000 (14:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 14:53:30 +0000 (14:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/log_stream.c

index 92f7f41a11015dbd32620ba2d02db33d63fb4f9f..a8f20a675e6d6878a4c1d3928c8acfd74a954a06 100644 (file)
@@ -160,7 +160,7 @@ int pakfire_log_stream_in_parent(struct pakfire_log_stream* stream, sd_event* lo
        int r;
 
        // Close the write end of the pipe
-       if (stream->pipe[1]) {
+       if (stream->pipe[1] >= 0) {
                close(stream->pipe[1]);
                stream->pipe[1] = -1;
        }
@@ -188,7 +188,7 @@ int pakfire_log_stream_in_parent(struct pakfire_log_stream* stream, sd_event* lo
 */
 int pakfire_log_stream_in_child(struct pakfire_log_stream* stream) {
        // Close the read end of the pipe
-       if (stream->pipe[0]) {
+       if (stream->pipe[0] >= 0) {
                close(stream->pipe[0]);
                stream->pipe[0] = -1;
        }