Ancora correzioni sulle varie versioni di server.
[gapil.git] / sources / TCP_echod.c
index 049155744c919942c335a3a5f3b818ce0005990f..25a457187e4d000071e59623967d67938163a216 100644 (file)
@@ -26,7 +26,7 @@
  *
  * Usage: echod -h give all info
  *
- * $Id: TCP_echod.c,v 1.8 2003/07/27 14:28:19 piccardi Exp $ 
+ * $Id: TCP_echod.c,v 1.10 2003/07/29 22:41:36 piccardi Exp $ 
  *
  ****************************************************************/
 /* 
@@ -41,7 +41,7 @@
 #include <syslog.h>      /* syslog system functions */
 #include <signal.h>      /* signal functions */
 #include <errno.h>       /* error code */
-#include <string.h>      /* error code */
+#include <string.h>      /* error strings */
 #include "Gapil.h"
 
 #define BACKLOG 10
@@ -104,7 +104,7 @@ int main(int argc, char *argv[])
      * 
      * ***********************************************************/
     /* install SIGCHLD handler */
-    Signal(SIGCHLD, HandSigCHLD);  /* establish handler */
+    SignalRestart(SIGCHLD, HandSigCHLD);  /* establish handler */
     /* create socket */
     if ( (list_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
        perror("Socket creation error");
@@ -209,7 +209,7 @@ void ServEcho(int sockfd) {
            }
        }
        nwrite = FullWrite(sockfd, buffer, nread);
-       if (nwrite < 0) {
+       if (nwrite) {
            snprintf(debug, MAXLINE+20, "Errore in scrittura: %s \n", 
                     strerror(errno));
            if (demonize) {          /* daemon mode */
@@ -234,8 +234,8 @@ void ServEcho(int sockfd) {
  * routine to print error on stout or syslog
  */
 void PrintErr(char * error) {
-    if (demonize) {          /* daemon mode */
-       syslog(LOG_ERR, error);
+    if (demonize) {                       /* daemon mode */
+       syslog(LOG_ERR, "%s: %m", error); /* log string and error message */
     } else {
        perror(error);
     }