]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
pty: Ensure to register SIGWINCH in the parent process
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Jan 2025 16:32:57 +0000 (16:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Jan 2025 16:32:57 +0000 (16:32 +0000)
This makes the entire terminal resizing work again...

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/pty.c

index cbc1ad23550b728c80c2b3bc18ffd844cd256d7e..0c9ab9d841a89a89a2b0d127a19a220d77208145 100644 (file)
@@ -1075,12 +1075,20 @@ static int pakfire_pty_setup(sd_event_source* source, int fd, uint32_t events, v
                        pty->master.fd, EPOLLIN|EPOLLOUT|EPOLLET, pakfire_pty_master, pty);
        if (r < 0) {
                ERROR(pty->ctx, "Could not add the master file descriptor: %s\n", strerror(-r));
-               return r;
+               return -errno;
        }
 
        // Set description
        sd_event_source_set_description(pty->master.event, "pty-master");
 
+       // Listen to SIGWINCH
+       r = sd_event_add_signal(pty->loop, &pty->sigwinch_event,
+                       SIGWINCH|SD_EVENT_SIGNAL_PROCMASK, pakfire_pty_SIGWINCH, pty);
+       if (r < 0) {
+               ERROR(pty->ctx, "Could not register SIGWINCH: %s\n", strerror(-r));
+               return -errno;
+       }
+
        // Setup forwarding
        r = pakfire_pty_setup_forwarding(pty);
        if (r < 0)
@@ -1264,14 +1272,6 @@ int pakfire_pty_open(struct pakfire_pty* pty) {
        close(pty->master.fd);
        pty->master.fd = -EBADF;
 
-       // Listen to SIGWINCH
-       r = sd_event_add_signal(pty->loop, &pty->sigwinch_event,
-                       SIGWINCH|SD_EVENT_SIGNAL_PROCMASK, pakfire_pty_SIGWINCH, pty);
-       if (r < 0) {
-               ERROR(pty->ctx, "Could not register SIGWINCH: %s\n", strerror(-r));
-               return r;
-       }
-
        return 0;
 }