static bool teeout = false; /* output to output and stdout */
static bool stop = false;
static bool no_conio = false;
+static int timeout = 0;
static int argc;
static int numdir;
static int numcon;
" -dt print timestamp in debug output\n"
" -n no conio\n"
" -s no signals\n"
+" -u <nn> set command execution timeout to <nn> seconds\n"
" -t test - read configuration and exit\n"
" -? print this message.\n"
"\n"), 2000, HOST_OS, DISTNAME, DISTVER);
bool at_prompt = false;
int tty_input = isatty(fileno(input));
int stat;
+ btimer_t *tid;
for ( ;; ) {
if (at_prompt) { /* don't prompt multiple times */
break; /* error or interrupt */
} else if (stat == 0) { /* timeout */
if (strcmp(prompt, "*") == 0) {
+ if (timeout) tid = start_bsock_timer(UA_sock, timeout);
bnet_fsend(UA_sock, ".messages");
+ if (timeout) stop_bsock_timer(tid);
} else {
continue;
}
}
continue;
}
+ if (timeout) tid = start_bsock_timer(UA_sock, timeout);
if (!bnet_send(UA_sock)) { /* send command */
+ if (timeout) stop_bsock_timer(tid);
break; /* error */
}
+ if (timeout) stop_bsock_timer(tid);
}
if (strcmp(UA_sock->msg, ".quit") == 0 || strcmp(UA_sock->msg, ".exit") == 0) {
break;
}
+ if (timeout) tid = start_bsock_timer(UA_sock, timeout);
while ((stat = bnet_recv(UA_sock)) >= 0) {
if (at_prompt) {
if (!stop) {
sendit(UA_sock->msg);
}
}
+ if (timeout) stop_bsock_timer(tid);
if (usrbrk() > 1) {
break;
} else {
working_directory = "/tmp";
args = get_pool_memory(PM_FNAME);
- while ((ch = getopt(argc, argv, "bc:d:nst?")) != -1) {
+ while ((ch = getopt(argc, argv, "bc:d:nstu:?")) != -1) {
switch (ch) {
case 'c': /* configuration file */
if (configfile != NULL) {
test_config = true;
break;
+ case 'u':
+ timeout = atoi(optarg);
+ break;
+
case '?':
default:
usage();
(void)WSA_Init(); /* Initialize Windows sockets */
+ start_watchdog(); /* Start socket watchdog */
+
LockRes();
numdir = 0;
foreach_res(dir, R_DIRECTOR) {
exit(1);
}
already_here = true;
+ stop_watchdog();
config->free_resources();
free(config);
config = NULL;