]> git.ipfire.org Git - pakfire.git/commitdiff
pty: Add more logging when reading/writing
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Mar 2025 17:08:04 +0000 (17:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Mar 2025 17:08:04 +0000 (17:08 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/pty.c

index 88c00ca545f4f073f6be77c58160cdf5e65d8f95..241071a374daa6329d5f750e66697c788bb2d83e 100644 (file)
@@ -415,6 +415,8 @@ static int pakfire_pty_fill_buffer(struct pakfire_pty* pty, int fd, struct pakfi
                if (bytes_read < 0)
                        return bytes_read;
 
+               DEBUG(pty->ctx, "Read %zd byte(s) from input callback\n", bytes_read);
+
        // Otherwise read from the file descriptor
        } else if (fd >= 0) {
                bytes_read = read(fd, stdio->buffer + stdio->buffered, sizeof(stdio->buffer) - stdio->buffered);
@@ -422,6 +424,8 @@ static int pakfire_pty_fill_buffer(struct pakfire_pty* pty, int fd, struct pakfi
                // Abort on errors
                if (bytes_read < 0)
                        return -errno;
+
+               DEBUG(pty->ctx, "Read %zd byte(s) from fd=%d\n", bytes_read, fd);
        }
 
        // Successful read
@@ -597,6 +601,8 @@ static int pakfire_pty_drain_buffer(struct pakfire_pty* pty, int fd, struct pakf
                if (bytes_written < 0)
                        return bytes_written;
 
+               DEBUG(pty->ctx, "Sent %zd byte(s) to output callback\n", bytes_written);
+
        // Otherwise we write to the file descriptor
        } else if (fd >= 0) {
                bytes_written = write(fd, stdio->buffer, stdio->buffered);
@@ -604,6 +610,8 @@ static int pakfire_pty_drain_buffer(struct pakfire_pty* pty, int fd, struct pakf
                // Abort on error
                if (bytes_written < 0)
                        return -errno;
+
+               DEBUG(pty->ctx, "Wrote %zd byte(s) to fd=%d\n", bytes_written, fd);
        }
 
        // Successful write
@@ -635,8 +643,9 @@ static int pakfire_pty_forward(struct pakfire_pty* pty) {
                        ((pty->master.io & PAKFIRE_PTY_READY_TO_READ) && !pakfire_pty_buffer_is_full(pty, &pty->stdout)) ||
                        ((pty->stdout.io & PAKFIRE_PTY_READY_TO_WRITE) && pakfire_pty_buffer_has_data(pty, &pty->stdout))
                ) {
-               // DEBUG(pty->ctx, "PTY forward stdin=%x %zu, stdout=%x %zu, %x\n",
-               //      pty->stdin.io, pty->stdin.buffered, pty->stdout.io, pty->stdout.buffered, pty->master.io);
+               // DEBUG(pty->ctx, "PTY forward stdin=%x %zu, stdout=%x %zu, %x, draining=%d, drained=%d\n",
+               //      pty->stdin.io, pty->stdin.buffered, pty->stdout.io, pty->stdout.buffered, pty->master.io,
+               //      pty->state == PAKFIRE_PTY_STATE_DRAINING, pakfire_pty_drained(pty));
 
                // Read from standard input
                if (pty->stdin.io & PAKFIRE_PTY_READY_TO_READ) {