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