X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FTCP_echod.c;h=fe14ea31f2f9657c74765335c136057927cd7e22;hp=25a457187e4d000071e59623967d67938163a216;hb=7f87146842e5e91ef5335ff7a44e0d6d622812f0;hpb=efe29e351db06b5f8cc7dd8280d00eee483157a7 diff --git a/sources/TCP_echod.c b/sources/TCP_echod.c index 25a4571..fe14ea3 100644 --- a/sources/TCP_echod.c +++ b/sources/TCP_echod.c @@ -26,7 +26,7 @@ * * Usage: echod -h give all info * - * $Id: TCP_echod.c,v 1.10 2003/07/29 22:41:36 piccardi Exp $ + * $Id: TCP_echod.c,v 1.11 2003/08/02 19:54:11 piccardi Exp $ * ****************************************************************/ /* @@ -60,6 +60,7 @@ int main(int argc, char *argv[]) */ int list_fd, conn_fd; int waiting = 0; + int compat = 0; pid_t pid; struct sockaddr_in serv_add, cli_add; socklen_t len; @@ -70,7 +71,7 @@ int main(int argc, char *argv[]) */ int i; opterr = 0; /* don't want writing to stderr */ - while ( (i = getopt(argc, argv, "hdiw:")) != -1) { + while ( (i = getopt(argc, argv, "hdicw:")) != -1) { switch (i) { /* * Handling options @@ -83,6 +84,9 @@ int main(int argc, char *argv[]) case 'i': demonize = 0; break; + case 'c': + compat = 1; + break; case 'd': debugging = 1; break; @@ -103,8 +107,12 @@ int main(int argc, char *argv[]) * Main code beginning * * ***********************************************************/ - /* install SIGCHLD handler */ - SignalRestart(SIGCHLD, HandSigCHLD); /* establish handler */ + /* Main code begin here */ + if (compat) { /* install signal handler */ + Signal(SIGCHLD, HandSigCHLD); /* non restarting handler */ + } else { + SignalRestart(SIGCHLD, HandSigCHLD); /* restarting handler */ + } /* create socket */ if ( (list_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("Socket creation error"); @@ -186,6 +194,7 @@ void usage(void) { printf(" -h print this help\n"); printf(" -d write debug info\n"); printf(" -i use interactively\n"); + printf(" -c disable BSD semantics\n"); printf(" -w N wait N sec. before calling accept\n"); exit(1); } @@ -196,7 +205,6 @@ void ServEcho(int sockfd) { char buffer[MAXLINE]; int nread, nwrite; char debug[MAXLINE+20]; - int size; /* main loop, reading 0 char means client close connection */ while ( (nread = read(sockfd, buffer, MAXLINE)) != 0) { if (nread < 0) {