forked from github/abduco
added return value based on pressed key
This commit is contained in:
parent
64d897db14
commit
0f89851632
27
client.c
27
client.c
|
|
@ -123,13 +123,30 @@ static int client_mainloop(void) {
|
|||
debug("client-stdin: %c\n", pkt.u.msg[0]);
|
||||
if (client.await_command) {
|
||||
client.await_command = false;
|
||||
int rv = 0;
|
||||
switch (pkt.u.msg[0]) {
|
||||
case 'd':
|
||||
pkt.type = MSG_DETACH;
|
||||
pkt.len = 0;
|
||||
client_send_packet(&pkt);
|
||||
close(server.socket);
|
||||
return RV_DETACH;
|
||||
rv = RV_DETACH;
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
rv = RV_DETACH-(int)(pkt.u.msg[0]-'0')-1;
|
||||
break;
|
||||
}
|
||||
if (rv != 0) {
|
||||
pkt.type = MSG_DETACH;
|
||||
pkt.len = 0;
|
||||
client_send_packet(&pkt);
|
||||
close(server.socket);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
pkt.len = len;
|
||||
|
|
|
|||
4
splex.c
4
splex.c
|
|
@ -534,8 +534,8 @@ static bool attach_session(const char *name, const bool terminate) {
|
|||
client_setup_terminal();
|
||||
int status = client_mainloop();
|
||||
client_restore_terminal();
|
||||
if (status == RV_DETACH) {
|
||||
info("detached");
|
||||
if (status < RV_DETACH) {
|
||||
info("detached with return value %d", status);
|
||||
} else if (status == -EIO) {
|
||||
info("exited due to I/O errors");
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue