From 1194e7f82926e8278b8d525258d6bdf86ad25f51 Mon Sep 17 00:00:00 2001
From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Thu, 24 Oct 2002 15:29:05 +0000
Subject: [PATCH] Make sure to close all open file descriptors after forking,
 and before looking for new devices.  Don't register devices that do not have
 all needed SMART capability.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@116 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/smartd.c   | 11 +++++++----
 sm5/smartd.cpp | 11 +++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/sm5/smartd.c b/sm5/smartd.c
index 4266f28ab..b880cd142 100644
--- a/sm5/smartd.c
+++ b/sm5/smartd.c
@@ -37,7 +37,7 @@
 #include "ataprint.h"
 
 extern const char *CVSid1, *CVSid2;
-const char *CVSid3="$Id: smartd.c,v 1.27 2002/10/24 15:25:27 ballen4705 Exp $" 
+const char *CVSid3="$Id: smartd.c,v 1.28 2002/10/24 15:29:05 ballen4705 Exp $" 
 CVSID1 CVSID4 CVSID7;
 
 int daemon_init(void){
@@ -457,12 +457,15 @@ int main (int argc, char **argv){
   }
   
   printhead();
-  
+ 
+
+   // If we are running in background as a daemon, call 
+  // a routines that forks then closes file descriptors. 
   if (!debugmode){
     daemon_init();
   }
-  
-  /* fork into independent process */
+ 
+  // routines that look for devices on ata and scsi bus 
   atadevicescan (atadevicesptr); 
   scsidevicescan (scsidevicesptr);
   
diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp
index 7640d330d..995dbeab5 100644
--- a/sm5/smartd.cpp
+++ b/sm5/smartd.cpp
@@ -37,7 +37,7 @@
 #include "ataprint.h"
 
 extern const char *CVSid1, *CVSid2;
-const char *CVSid3="$Id: smartd.cpp,v 1.27 2002/10/24 15:25:27 ballen4705 Exp $" 
+const char *CVSid3="$Id: smartd.cpp,v 1.28 2002/10/24 15:29:05 ballen4705 Exp $" 
 CVSID1 CVSID4 CVSID7;
 
 int daemon_init(void){
@@ -457,12 +457,15 @@ int main (int argc, char **argv){
   }
   
   printhead();
-  
+ 
+
+   // If we are running in background as a daemon, call 
+  // a routines that forks then closes file descriptors. 
   if (!debugmode){
     daemon_init();
   }
-  
-  /* fork into independent process */
+ 
+  // routines that look for devices on ata and scsi bus 
   atadevicescan (atadevicesptr); 
   scsidevicescan (scsidevicesptr);
   
-- 
GitLab