diff options
author | nicm <nicm> | 2017-04-19 14:00:28 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-04-19 14:00:28 +0000 |
commit | 53fde21bb85c37c35854069ec95377ecc86750ee (patch) | |
tree | c99c254393c6330a16d0337bd65403d10cb94cf2 /server-client.c | |
parent | 689f4bfac22597e7fd2090373bdffe4df1ed5a34 (diff) | |
download | rtmux-53fde21bb85c37c35854069ec95377ecc86750ee.tar.gz rtmux-53fde21bb85c37c35854069ec95377ecc86750ee.tar.bz2 rtmux-53fde21bb85c37c35854069ec95377ecc86750ee.zip |
Add a suspend helper function, and do not allow detaching or suspending
while already doing so.
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/server-client.c b/server-client.c index f4fc915b..ca1d1508 100644 --- a/server-client.c +++ b/server-client.c @@ -49,7 +49,7 @@ static void server_client_dispatch_command(struct client *, struct imsg *); static void server_client_dispatch_identify(struct client *, struct imsg *); static void server_client_dispatch_shell(struct client *); -/* Idenfity mode callback. */ +/* Identify mode callback. */ static void server_client_callback_identify(__unused int fd, __unused short events, void *data) { @@ -325,15 +325,30 @@ server_client_free(__unused int fd, __unused short events, void *arg) } } +/* Suspend a client. */ +void +server_client_suspend(struct client *c) +{ + struct session *s = c->session; + + if (s == NULL || (c->flags & CLIENT_DETACHING)) + return; + + tty_stop_tty(&c->tty); + c->flags |= CLIENT_SUSPENDED; + proc_send(c->peer, MSG_SUSPEND, -1, NULL, 0); +} + /* Detach a client. */ void server_client_detach(struct client *c, enum msgtype msgtype) { - struct session *s = c->session; + struct session *s = c->session; - if (s == NULL) + if (s == NULL || (c->flags & CLIENT_DETACHING)) return; + c->flags |= CLIENT_DETACHING; notify_client("client-detached", c); proc_send_s(c->peer, msgtype, s->name); } |