diff --git a/sm5/smartd.c b/sm5/smartd.c
index 36262fa64414d57599079a013fa77858e34308ba..bcf3ca2bee6344e62394610d0c609ad71224ac3d 100644
--- a/sm5/smartd.c
+++ b/sm5/smartd.c
@@ -37,23 +37,36 @@
 #include "ataprint.h"
 
 extern const char *CVSid1, *CVSid2;
-const char *CVSid3="$Id: smartd.c,v 1.25 2002/10/24 11:38:11 ballen4705 Exp $" 
+const char *CVSid3="$Id: smartd.c,v 1.26 2002/10/24 15:03:15 ballen4705 Exp $" 
 CVSID1 CVSID4 CVSID7;
 
 int daemon_init(void){
   pid_t pid;
-  
+  int i;  
+
   if ( (pid = fork()) < 0)
     // unable to fork!
-    return -1;
+    exit(1);
   else if (pid != 0)
-    // we are the parent process -- exit
+    // we are the parent process -- exit cleanly
     exit (0);
 
   // from here on, we are the child process
-  setsid ();
-  chdir("/");
+  setsid();
+
+  // close any open file descriptors
+  for (i=getdtablesize();i>=0;--i)
+    close(i);
+
+  // redirect any IO attempts to /dev/null
+  // open stdin
+  i=open("/dev/null",O_RDWR);
+  // stdout
+  dup(i);
+  // stderr
+  dup(i);
   umask(0);
+  chdir("/");
   return(0);
 }
 
@@ -88,7 +101,7 @@ void pout(char *fmt, ...){
 
 
 void printhead(){
-  printout(LOG_INFO,"smartd version %d.%d-%d - S.M.A.R.T. Daemon\n"
+  printout(LOG_INFO,"smartd version %d.%d-%d - S.M.A.R.T. Daemon.\n"
 	   "Home page is %s\n\n",
            RELEASE_MAJOR, RELEASE_MINOR,SMARTMONTOOLS_VERSION,PROJECTHOME);
 }
diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp
index f7ac3107f919306f8833b46dcd6e4d2678d7e5ad..de84844377e75b3c6d8ca0fd1d8fc31f1106a2e1 100644
--- a/sm5/smartd.cpp
+++ b/sm5/smartd.cpp
@@ -37,23 +37,36 @@
 #include "ataprint.h"
 
 extern const char *CVSid1, *CVSid2;
-const char *CVSid3="$Id: smartd.cpp,v 1.25 2002/10/24 11:38:11 ballen4705 Exp $" 
+const char *CVSid3="$Id: smartd.cpp,v 1.26 2002/10/24 15:03:15 ballen4705 Exp $" 
 CVSID1 CVSID4 CVSID7;
 
 int daemon_init(void){
   pid_t pid;
-  
+  int i;  
+
   if ( (pid = fork()) < 0)
     // unable to fork!
-    return -1;
+    exit(1);
   else if (pid != 0)
-    // we are the parent process -- exit
+    // we are the parent process -- exit cleanly
     exit (0);
 
   // from here on, we are the child process
-  setsid ();
-  chdir("/");
+  setsid();
+
+  // close any open file descriptors
+  for (i=getdtablesize();i>=0;--i)
+    close(i);
+
+  // redirect any IO attempts to /dev/null
+  // open stdin
+  i=open("/dev/null",O_RDWR);
+  // stdout
+  dup(i);
+  // stderr
+  dup(i);
   umask(0);
+  chdir("/");
   return(0);
 }
 
@@ -88,7 +101,7 @@ void pout(char *fmt, ...){
 
 
 void printhead(){
-  printout(LOG_INFO,"smartd version %d.%d-%d - S.M.A.R.T. Daemon\n"
+  printout(LOG_INFO,"smartd version %d.%d-%d - S.M.A.R.T. Daemon.\n"
 	   "Home page is %s\n\n",
            RELEASE_MAJOR, RELEASE_MINOR,SMARTMONTOOLS_VERSION,PROJECTHOME);
 }