X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=listati%2FTCP_echod_second.c;h=78557afdb04fd9f9a16e3a9fb406d59b3ac9f1f4;hp=d5c8bba93c29bd192f8021ec45ca687c036582a6;hb=7f87146842e5e91ef5335ff7a44e0d6d622812f0;hpb=efe29e351db06b5f8cc7dd8280d00eee483157a7 diff --git a/listati/TCP_echod_second.c b/listati/TCP_echod_second.c index d5c8bba..78557af 100644 --- a/listati/TCP_echod_second.c +++ b/listati/TCP_echod_second.c @@ -1,7 +1,23 @@ int main(int argc, char *argv[]) { ... + int waiting = 0; + int compat = 0; ... + + /* Main code begin here */ + if (compat) { /* install signal handler */ + Signal(SIGCHLD, HandSigCHLD); /* non restarting handler */ + } else { + SignalRestart(SIGCHLD, HandSigCHLD); /* restarting handler */ + } + ... + + /* main body */ + if (listen(list_fd, BACKLOG) < 0 ) { + PrintErr("listen error"); + exit(1); + } if (waiting) sleep(waiting); /* handle echo to client */ while (1) { @@ -22,7 +38,7 @@ int main(int argc, char *argv[]) } } /* fork to handle connection */ - ... ... } + return; }