enough.
I added a command line arg to increase it if needed.
Watchdog defaults to 5 seconds but you can use -w to extend it if you
need to.
+void check_exit_code(int code, void *arg)
+{
+ if (code == SIGALRM)
+ fprintf(stderr, "\nWatch dog time out.\n");
+}
+
+
int a;
char cmd[SIZ];
char buf[SIZ];
int a;
char cmd[SIZ];
char buf[SIZ];
struct timeval tv;
int ret, err;
int server_shutting_down = 0;
struct timeval tv;
int ret, err;
int server_shutting_down = 0;
+
+ on_exit (check_exit_code, NULL);
strcpy(ctdl_home_directory, DEFAULT_PORT);
strcpy(ctdl_home_directory, DEFAULT_PORT);
sizeof relhome);
home_specified = 1;
home=1;
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, " ");
} else {
if (!IsEmptyStr(cmd))
strcat(cmd, " ");
ctdl_home_directory);
fflush(stderr);
ctdl_home_directory);
fflush(stderr);
signal(SIGALRM, nq_cleanup); /* Set up a watchdog type timer in case we hang */
np_attach_to_server(UDS, ctdl_home_directory);
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);
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 {
}
} else if (buf[0] == '4') {
do {
- 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");
} while (strcmp(buf, "000"));
CtdlIPC_chat_send(ipc, "\n");
CtdlIPC_chat_send(ipc, "000");