<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -35,6 +35,7 @@
 #endif
 
 #include &lt;fcntl.h&gt;
+#include &lt;stdio.h&gt;
 #include &lt;stdlib.h&gt;
 #include &lt;unistd.h&gt;
 
@@ -56,15 +57,33 @@ int daemonize(int nochdir, int noclose)
     if (setsid() == -1)
         return (-1);
 
-    if (nochdir == 0)
-        (void)chdir(&quot;/&quot;);
+    if (nochdir == 0) {
+        if(chdir(&quot;/&quot;) != 0) {
+            perror(&quot;chdir&quot;);
+            return (-1);
+        }
+    }
 
     if (noclose == 0 &amp;&amp; (fd = open(&quot;/dev/null&quot;, O_RDWR, 0)) != -1) {
-        (void)dup2(fd, STDIN_FILENO);
-        (void)dup2(fd, STDOUT_FILENO);
-        (void)dup2(fd, STDERR_FILENO);
-        if (fd &gt; STDERR_FILENO)
-            (void)close(fd);
+        if(dup2(fd, STDIN_FILENO) &lt; 0) {
+            perror(&quot;dup2 stdin&quot;);
+            return (-1);
+        }
+        if(dup2(fd, STDOUT_FILENO) &lt; 0) {
+            perror(&quot;dup2 stdout&quot;);
+            return (-1);
+        }
+        if(dup2(fd, STDERR_FILENO) &lt; 0) {
+            perror(&quot;dup2 stderr&quot;);
+            return (-1);
+        }
+
+        if (fd &gt; STDERR_FILENO) {
+            if(close(fd) &lt; 0) {
+                perror(&quot;close&quot;);
+                return (-1);
+            }
+        }
     }
     return (0);
 }</diff>
      <filename>daemon.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ad00048ad5373ad62c96c47845c3221ab47eaa7e</id>
    </parent>
  </parents>
  <author>
    <name>Dustin Sallings</name>
    <email>dustin@spy.net</email>
  </author>
  <url>http://github.com/tmaesaka/memcached/commit/2c196ed6cacfd3eea845a3b9a5758a698096d97b</url>
  <id>2c196ed6cacfd3eea845a3b9a5758a698096d97b</id>
  <committed-date>2009-01-20T11:23:14-08:00</committed-date>
  <authored-date>2009-01-19T15:45:38-08:00</authored-date>
  <message>Build fixes for ubuntu 8.10/64.

gcc seems to have been wise to all of the syscalls being cast to void
to avoid doing real result checking in unlikely errors.</message>
  <tree>dda6ba0ad959dc58e60f95f4f5f14952fae8ff1c</tree>
  <committer>
    <name>Dustin Sallings</name>
    <email>dustin@spy.net</email>
  </committer>
</commit>
