From 3e86ffe24bdf6fa55a85192d9818d0bc963c7f0f Mon Sep 17 00:00:00 2001 From: Nathan Straz Date: Mon, 20 Feb 2012 10:12:36 -0500 Subject: Move error message and exit from signal handler. --- qarsh.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'qarsh.c') diff --git a/qarsh.c b/qarsh.c index f582c92..4b389f4 100644 --- a/qarsh.c +++ b/qarsh.c @@ -56,6 +56,7 @@ hbeat_t qarsh_hb; /* Heartbeat handle */ int signal_to_send = 0; int sigs_to_propogate[] = { SIGINT, SIGTERM, SIGHUP, SIGUSR1, SIGUSR2 }; sigset_t pselect_sigmask; +int connection_timeout = 0; void usage() @@ -107,8 +108,7 @@ sig_handler(int sig) void sig_alrm_handler(int sig) { - fprintf(stderr, "Could not connect to remote host\n"); - exit(127); + connection_timeout = 1; } void @@ -517,6 +517,10 @@ again: alarm(CONNECT_TIMEOUT); qarsh_fd = connect_to_host(host, port, &qarsh_ss_family); alarm(0); + if (connection_timeout) { + fprintf(stderr, "Could not connect to remote host\n"); + exit(127); + } if (qarsh_fd == -1) { if (errno == 0) { -- cgit