}
+void check_exit_code(int code, void *arg)
+{
+ if (code == SIGALRM)
+ fprintf(stderr, "\nWatch dog time out.\n");
+}
+
+
/*
* main
*/
int a;
char cmd[SIZ];
char buf[SIZ];
+ int watchdog = 5;
int relh=0;
int home=0;
struct timeval tv;
int ret, err;
int server_shutting_down = 0;
+
+ on_exit (check_exit_code, NULL);
strcpy(ctdl_home_directory, DEFAULT_PORT);
sizeof relhome);
home_specified = 1;
home=1;
+ } else if (!strncmp(argv[a], "-w", 2)) {
+ watchdog = atoi(&argv[a][2]);
+ if (watchdog<1)
+ watchdog=1;
} else {
if (!IsEmptyStr(cmd))
strcat(cmd, " ");
ctdl_home_directory);
fflush(stderr);
- alarm(5);
+ alarm(watchdog);
signal(SIGALRM, nq_cleanup); /* Set up a watchdog type timer in case we hang */
np_attach_to_server(UDS, ctdl_home_directory);
if (buf[0] == '1') {
while (CtdlIPC_chat_recv(ipc, buf), strcmp(buf, "000")) {
printf("%s\n", buf);
- alarm(5); /* Kick the watchdog timer */
+ alarm(watchdog); /* Kick the watchdog timer */
}
} else if (buf[0] == '4') {
do {
fflush (stdout);
}
}
- alarm(5); /* Kick the watchdog timer */
+ alarm(watchdog); /* Kick the watchdog timer */
} while (strcmp(buf, "000"));
CtdlIPC_chat_send(ipc, "\n");
CtdlIPC_chat_send(ipc, "000");