daemon.c
changeset 131 b5ad49852adc
parent 79 1499176750b9
child 138 dff18d1ac2af
--- a/daemon.c
+++ b/daemon.c
@@ -32,7 +32,8 @@
     strftime (time_stamp, sizeof (time_stamp), "%a %d %T", localtime (&t));
     len = snprintf (response, sizeof (response), "%s %s", time_stamp, buffer);
 
-    write (fd, response, len);
+    if (write (fd, response, len) == -1)
+        perror ("write");
 }
 
 void sigproc ()
@@ -80,7 +81,10 @@
 
     sanity_check (argc, argv);
 
-    daemon (0, 0);
+    if (daemon (0, 0) == -1) {
+        perror ("daemon");
+        return EXIT_FAILURE;
+    }
     signal (SIGTERM, sigproc);
 
     for (;;) {