ptyfwd: rename handler to hangup_handler
We'll add another type of handler callback in the next commit, hence rename the existing handler to be more precise what it is about: handling hangups (either inline via tty, or explicit via user request)
This commit is contained in:
@@ -192,7 +192,7 @@ static int run(int argc, char *argv[]) {
|
||||
return log_error_errno(r, "Failed to set title: %m");
|
||||
}
|
||||
|
||||
pty_forward_set_handler(forward, pty_forward_handler, event);
|
||||
pty_forward_set_hangup_handler(forward, pty_forward_handler, event);
|
||||
|
||||
r = pidref_safe_fork_full(
|
||||
"(sd-ptyfwd)",
|
||||
|
||||
+1
-1
@@ -2220,7 +2220,7 @@ static int start_transient_service(sd_bus *bus) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create PTY forwarder: %m");
|
||||
|
||||
pty_forward_set_handler(c.forward, pty_forward_handler, &c);
|
||||
pty_forward_set_hangup_handler(c.forward, pty_forward_handler, &c);
|
||||
|
||||
/* Make sure to process any TTY events before we process bus events */
|
||||
(void) pty_forward_set_priority(c.forward, SD_EVENT_PRIORITY_IMPORTANT);
|
||||
|
||||
+9
-9
@@ -101,8 +101,8 @@ struct PTYForward {
|
||||
usec_t escape_timestamp;
|
||||
unsigned escape_counter;
|
||||
|
||||
PTYForwardHandler handler;
|
||||
void *userdata;
|
||||
PTYForwardHangupHandler hangup_handler;
|
||||
void *hangup_userdata;
|
||||
|
||||
char *background_color;
|
||||
AnsiColorState ansi_color_state;
|
||||
@@ -192,10 +192,10 @@ static int pty_forward_done(PTYForward *f, int rcode) {
|
||||
f->done = true;
|
||||
pty_forward_disconnect(f);
|
||||
|
||||
if (f->handler)
|
||||
return f->handler(f, rcode, f->userdata);
|
||||
else
|
||||
return sd_event_exit(e, rcode < 0 ? EXIT_FAILURE : rcode);
|
||||
if (f->hangup_handler)
|
||||
return f->hangup_handler(f, rcode, f->hangup_userdata);
|
||||
|
||||
return sd_event_exit(e, rcode < 0 ? EXIT_FAILURE : rcode);
|
||||
}
|
||||
|
||||
static bool look_for_escape(PTYForward *f, const char *buffer, size_t n) {
|
||||
@@ -1084,11 +1084,11 @@ bool pty_forward_get_ignore_vhangup(PTYForward *f) {
|
||||
return FLAGS_SET(f->flags, PTY_FORWARD_IGNORE_VHANGUP);
|
||||
}
|
||||
|
||||
void pty_forward_set_handler(PTYForward *f, PTYForwardHandler cb, void *userdata) {
|
||||
void pty_forward_set_hangup_handler(PTYForward *f, PTYForwardHangupHandler cb, void *userdata) {
|
||||
assert(f);
|
||||
|
||||
f->handler = cb;
|
||||
f->userdata = userdata;
|
||||
f->hangup_handler = cb;
|
||||
f->hangup_userdata = userdata;
|
||||
}
|
||||
|
||||
bool pty_forward_drain(PTYForward *f) {
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ typedef enum PTYForwardFlags {
|
||||
PTY_FORWARD_DUMB_TERMINAL = 1 << 3,
|
||||
} PTYForwardFlags;
|
||||
|
||||
typedef int (*PTYForwardHandler)(PTYForward *f, int rcode, void *userdata);
|
||||
typedef int (*PTYForwardHangupHandler)(PTYForward *f, int rcode, void *userdata);
|
||||
|
||||
#define N_PTY_FORWARD_SIGNALS 7
|
||||
extern const int pty_forward_signals[N_PTY_FORWARD_SIGNALS];
|
||||
@@ -34,7 +34,7 @@ PTYForward* pty_forward_free(PTYForward *f);
|
||||
int pty_forward_set_ignore_vhangup(PTYForward *f, bool ignore_vhangup);
|
||||
bool pty_forward_get_ignore_vhangup(PTYForward *f);
|
||||
|
||||
void pty_forward_set_handler(PTYForward *f, PTYForwardHandler handler, void *userdata);
|
||||
void pty_forward_set_hangup_handler(PTYForward *f, PTYForwardHangupHandler handler, void *userdata);
|
||||
|
||||
bool pty_forward_drain(PTYForward *f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user