X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Fclient.c;h=7b98f66129bb717914495cdbc7b38305667ae300;hb=81bd571ef4d8b2b9762738cf70cd5b644c368dc5;hp=a3147d551dd4a91bd74dec75519e7131e2740193;hpb=5b3f4e20affe90bff9909272a933834247a2ed9d;p=spider.git diff --git a/src/client.c b/src/client.c index a3147d55..7b98f661 100644 --- a/src/client.c +++ b/src/client.c @@ -574,7 +574,7 @@ lend:; /* * set up the various mode flags, NL endings and things */ -void setmode(char *m) +void setconntype(char *m) { connsort = strlower(m); if (eq(connsort, "telnet") || eq(connsort, "local") || eq(connsort, "nlonly")) { @@ -723,13 +723,8 @@ void process_node() void term_timeout(int i) { /* none of this is going to be reused so don't bother cleaning up properly */ - if (in && in->t_set) - tcsetattr(0, TCSANOW, &in->t); - if (node) { - shutdown(node->cnum, 3); - close(node->cnum); - } - exit(i); + tcflush(0, TCIOFLUSH); + kill(getpid(), 9); /* commit suicide */ } void terminate(int i) @@ -809,9 +804,9 @@ lerr: die("Must have at least a callsign (for now)"); if (optind < argc) { - setmode(argv[optind]); + setconntype(argv[optind]); } else { - setmode("local"); + setconntype("local"); } /* this is kludgy, but hey so is the rest of this! */ @@ -825,8 +820,10 @@ void connect_to_node() struct hostent *hp, *gethostbyname(); struct sockaddr_in server; int nodef; + int one = 1; sel_t *sp; - + struct linger lg; + if ((hp = gethostbyname(node_addr)) == 0) die("Unknown host tcp host %s for printer", node_addr); @@ -842,6 +839,15 @@ void connect_to_node() if (connect(nodef, (struct sockaddr *) &server, sizeof server) < 0) { die("Error on connect to %s port %d (%d)", node_addr, node_port, errno); } + + memset(&lg, 0, sizeof lg); + if (setsockopt(nodef, SOL_SOCKET, SO_LINGER, &lg, sizeof lg) < 0) { + die("Error on SO_LINGER to %s port %d (%d)", node_addr, node_port, errno); + } + if (setsockopt(nodef, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one) < 0) { + die("Error on SO_KEEPALIVE to %s port %d (%d)", node_addr, node_port, errno); + } + node = fcb_new(nodef, MSG); node->sp = sel_open(nodef, node, "Msg System", fcb_handler, MSG, SEL_INPUT); @@ -901,7 +907,6 @@ main(int argc, char *argv[]) #ifdef SIGPWR signal(SIGPWR, terminate); #endif - signal(SIGCLD, reaper); /* init a few things */ chain_init(&echobase); @@ -909,8 +914,7 @@ main(int argc, char *argv[]) /* connect up stdin */ in = fcb_new(0, TEXT); in->sp = sel_open(0, in, "STDIN", fcb_handler, TEXT, SEL_INPUT); - if (tcgetattr(0, &in->t) < 0) { -/* echo = 0; */ + if (!isatty(0) || tcgetattr(0, &in->t) < 0) { in->echo = echo; in->t_set = 0; } else {