PAKFIRE_PTY_READY_TO_READ = (1 << 0),
PAKFIRE_PTY_READY_TO_WRITE = (1 << 1),
} io;
+
+ // Event Source
+ sd_event_source* event;
};
struct pakfire_pty {
return r;
// Add standard input to the event loop
- r = sd_event_add_io(pty->loop, NULL,
+ r = sd_event_add_io(pty->loop, &pty->stdin.event,
pty->stdin.fd, EPOLLIN|EPOLLET, pakfire_pty_stdin, pty);
if (r)
return r;
+ // Set description
+ sd_event_source_set_description(pty->stdin.event, "pty-stdin");
+
// Add standard output to the event loop
- r = sd_event_add_io(pty->loop, NULL,
+ r = sd_event_add_io(pty->loop, &pty->stdout.event,
pty->stdout.fd, EPOLLOUT|EPOLLET, pakfire_pty_stdout, pty);
if (r)
return r;
+ // Set description
+ sd_event_source_set_description(pty->stdout.event, "pty-stdout");
+
return 0;
}
return r;
// Add the master file descriptor to the event loop
- r = sd_event_add_io(pty->loop, NULL, pty->master.fd,
- EPOLLIN|EPOLLOUT|EPOLLET, pakfire_pty_master, pty);
+ r = sd_event_add_io(pty->loop, &pty->master.event,
+ pty->master.fd, EPOLLIN|EPOLLOUT|EPOLLET, pakfire_pty_master, pty);
if (r < 0) {
CTX_ERROR(pty->ctx, "Could not add the master file descriptor: %s\n", strerror(-r));
return r;
}
+ // Set description
+ sd_event_source_set_description(pty->master.event, "pty-master");
+
// Do we need to set up PTY forwarding?
if (pty->flags & PAKFIRE_PTY_FORWARD) {
r = pakfire_pty_setup_forwarding(pty);
pakfire_pty_restore_attrs(pty, &pty->stdin);
if (pty->stdout.fd >= 0)
pakfire_pty_restore_attrs(pty, &pty->stdout);
-
+ if (pty->master.event)
+ sd_event_source_unref(pty->master.event);
+ if (pty->stdin.event)
+ sd_event_source_unref(pty->stdin.event);
+ if (pty->stdout.event)
+ sd_event_source_unref(pty->stdout.event);
if (pty->socket[0] >= 0)
close(pty->socket[0]);
if (pty->socket[1] >= 0)