mirror of
https://github.com/bstansell/conserver.git
synced 2025-04-23 18:13:36 +00:00
Merge pull request #54 from MyleneJ/add_k_option
console: Add 'k' option to exit on console-down
This commit is contained in:
commit
4396ff9456
console
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user