Merge pull request from MyleneJ/add_k_option

console: Add 'k' option to exit on console-down
This commit is contained in:
Bryan Stansell 2020-10-17 15:36:40 -07:00 committed by GitHub
commit 4396ff9456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

@ -1471,8 +1471,13 @@ CallUp(CONSFILE *pcf, char *pcMaster, char *pcMach, char *pcHow,
/* try to grok the state of the console */
FilePrint(pcf, FLAGFALSE, "%c%c=", chAttn, chEsc);
r = ReadReply(pcf, FLAGFALSE);
if (strncmp(r, "[unknown", 8) != 0 && strncmp(r, "[up]", 4) != 0)
FileWrite(cfstdout, FLAGFALSE, r, -1);
if (strncmp(r, "[unknown", 8) != 0 && strncmp(r, "[up]", 4) != 0) {
FileWrite(cfstdout, FLAGFALSE, r, -1);
if (config->exitdown == FLAGTRUE) {
printf("Device is down. Will exit with option 'k'\n");
kill(thepid, SIGTERM);
}
}
/* try to grok the version of the server */
FilePrint(pcf, FLAGFALSE, "%c%c%c", chAttn, chEsc, 0xD6);
@ -1905,7 +1910,7 @@ main(int argc, char **argv)
int fLocal;
static STRING *acPorts = (STRING *)0;
static char acOpts[] =
"7aAb:B:c:C:d:De:EfFhiIl:M:np:PqQrRsSt:uUvVwWxz:Z:";
"7aAb:B:c:C:d:De:EfFhikIl:M:np:PqQrRsSt:uUvVwWxz:Z:";
extern int optind;
extern int optopt;
extern char *optarg;
@ -2035,6 +2040,10 @@ main(int argc, char **argv)
pcCmd = "info";
break;
case 'k':
optConf->exitdown = FLAGTRUE;
break;
case 'l':
if ((optConf->username = StrDup(optarg)) == (char *)0)
OutOfMem();
@ -2232,6 +2241,13 @@ main(int argc, char **argv)
else
config->striphigh = FLAGFALSE;
if (optConf->exitdown != FLAGUNKNOWN)
config->exitdown = optConf->exitdown;
else if (pConfig->exitdown != FLAGUNKNOWN)
config->exitdown = pConfig->exitdown;
else
config->exitdown = FLAGFALSE;
if (optConf->escape != (char *)0)
ParseEsc(optConf->escape);
else if (pConfig->escape != (char *)0)

@ -12,6 +12,7 @@ typedef struct config {
char *port;
char *escape;
FLAG striphigh;
FLAG exitdown;
unsigned short replay;
unsigned short playback;
#if HAVE_OPENSSL