diff --git a/client.c b/client.c index 3d6d82b..ac49f43 100644 --- a/client.c +++ b/client.c @@ -63,6 +63,7 @@ static int client_mainloop(void) { sigprocmask(SIG_BLOCK, &blockset, NULL); client.need_resize = true; + client.await_command = false; Packet pkt = { .type = MSG_ATTACH, .u.i = client.flags, @@ -121,15 +122,21 @@ static int client_mainloop(void) { die("client-stdin"); if (len > 0) { debug("client-stdin: %c\n", pkt.u.msg[0]); + if (client.await_command) { + client.await_command = false; + if (pkt.u.msg[0]=='d') { + pkt.type = MSG_DETACH; + pkt.len = 0; + client_send_packet(&pkt); + close(server.socket); + return -1; + } + } pkt.len = len; if (KEY_REDRAW && pkt.u.msg[0] == KEY_REDRAW) { client.need_resize = true; } else if (pkt.u.msg[0] == KEY_DETACH) { - pkt.type = MSG_DETACH; - pkt.len = 0; - client_send_packet(&pkt); - close(server.socket); - return -1; + client.await_command = true; } else if (!(client.flags & CLIENT_READONLY)) { client_send_packet(&pkt); } diff --git a/splex.c b/splex.c index b56e6f4..22d8486 100644 --- a/splex.c +++ b/splex.c @@ -100,6 +100,7 @@ struct Client { CLIENT_LOWPRIORITY = 1 << 1, } flags; Client *next; + bool await_command; }; typedef struct {