forked from github/abduco
added testing mode and changed detach return value
This commit is contained in:
parent
9531cfcdac
commit
6c6b505327
16
splex.c
16
splex.c
|
|
@ -62,6 +62,8 @@
|
||||||
|
|
||||||
#define countof(arr) (sizeof(arr) / sizeof((arr)[0]))
|
#define countof(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||||
|
|
||||||
|
#define RV_DETACH -1000
|
||||||
|
|
||||||
enum PacketType {
|
enum PacketType {
|
||||||
MSG_CONTENT = 0,
|
MSG_CONTENT = 0,
|
||||||
MSG_ATTACH = 1,
|
MSG_ATTACH = 1,
|
||||||
|
|
@ -532,7 +534,7 @@ 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 == -1) {
|
if (status == RV_DETACH) {
|
||||||
info("detached");
|
info("detached");
|
||||||
} else if (status == -EIO) {
|
} else if (status == -EIO) {
|
||||||
info("exited due to I/O errors");
|
info("exited due to I/O errors");
|
||||||
|
|
@ -601,13 +603,13 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
server.name = basename(argv[0]);
|
server.name = basename(argv[0]);
|
||||||
gethostname(server.host+1, sizeof(server.host) - 1);
|
gethostname(server.host+1, sizeof(server.host) - 1);
|
||||||
|
while ((opt = getopt(argc, argv, "aAchlne:qrtvz")) != -1) {
|
||||||
while ((opt = getopt(argc, argv, "aAchlne:qrvz")) != -1) {
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'n':
|
case 'n':
|
||||||
|
case 't':
|
||||||
action = opt;
|
action = opt;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
|
|
@ -706,6 +708,14 @@ int main(int argc, char *argv[]) {
|
||||||
goto redo;
|
goto redo;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
if (!session_alive(server.session_name)) {
|
||||||
|
if (!create_session(server.session_name, cmd))
|
||||||
|
die("create-session");
|
||||||
|
}
|
||||||
|
if (!attach_session(server.session_name, true))
|
||||||
|
die("attach-session");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue