} state;
};
+static int pakfire_pty_has_flag(struct pakfire_pty* pty, int flag) {
+ return pty->flags & flag;
+}
+
static int pakfire_pty_restore_attrs(struct pakfire_pty* pty,
struct pakfire_pty_stdio* stdio) {
int r;
}
}
- // Enable RAW mode on standard input
- r = pakfire_pty_enable_raw_mode(pty, &pty->stdin);
- if (r)
- return r;
+ // Connect standard input unless we are in read-only mode
+ if (!pakfire_pty_has_flag(pty, PAKFIRE_PTY_READ_ONLY)) {
+ // Enable RAW mode on standard input
+ r = pakfire_pty_enable_raw_mode(pty, &pty->stdin);
+ if (r)
+ return r;
+
+ // Add standard input to the event loop
+ 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");
+ }
// Enable RAW mode on standard output
r = pakfire_pty_enable_raw_mode(pty, &pty->stdout);
if (r)
return r;
- // Add standard input to the event loop
- 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, &pty->stdout.event,
pty->stdout.fd, EPOLLOUT|EPOLLET, pakfire_pty_stdout, pty);