diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index 0ce74f5125f545b843d44ac4c5e8c304b0c85e84..b250f4e6efa0be51fb1cda9e8a69eb7deea38f0f 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.61 2002/11/28 09:02:55 ballen4705 Exp $
+$Id: CHANGELOG,v 1.62 2002/12/01 06:48:14 ballen4705 Exp $
 
 Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 
@@ -32,6 +32,14 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 CURRENT RELEASE (see VERSION file in this directory):
 
+  [BA] smartd: The syslog entries how have a single process number for
+  smartd, not two distinct numbers.  We do this by calling daemon_init()
+  before printing header message and before reading config file.  Some
+  perror() entries in the latter modified to print in the correct
+  place.
+
+smartmontools-5.0.48
+
   [BA] smartctl: The -O option to enable an Immediate off-line test
   did not print out the correct time that the test would take to
   complete.  This is because the test timer is volatile and not
diff --git a/sm5/VERSION b/sm5/VERSION
index 21e72e8ac3d7e23bd6532b5f1f4a6bdf8362e6cf..95f9650f0151d7c0d3aecf40355d88effbd5b7a7 100644
--- a/sm5/VERSION
+++ b/sm5/VERSION
@@ -1 +1 @@
-48
+49
diff --git a/sm5/smartd.c b/sm5/smartd.c
index 0ac0b66366292446b9e8bd94d48e8f0b4033f51d..371263d8e4fa33acb595cd5dc2b337cca5e2c593 100644
--- a/sm5/smartd.c
+++ b/sm5/smartd.c
@@ -47,7 +47,7 @@
 
 // CVS ID strings
 extern const char *CVSid1, *CVSid2;
-const char *CVSid6="$Id: smartd.c,v 1.76 2002/11/25 11:45:28 ballen4705 Exp $" 
+const char *CVSid6="$Id: smartd.c,v 1.77 2002/12/01 06:48:14 ballen4705 Exp $" 
 CVSID1 CVSID2 CVSID3 CVSID4 CVSID7;
 
 // global variable used for control of printing, passing arguments, etc.
@@ -1090,7 +1090,10 @@ int parseconfigline(int entry, int lineno,char *line){
   static int numtokens=0;
 
   if (!(copy=strdup(line))){
-    perror("no memory available to parse line");
+    if (errno<sys_nerr)
+      printout(LOG_INFO,"No memory to parse file: %s line %d, %s\n", CONFIGFILE, lineno, sys_errlist[errno]);
+    else
+      printout(LOG_INFO,"No memory to parse file: %s line %d\n", CONFIGFILE, lineno);
     exit(1);
   }
   
@@ -1115,7 +1118,7 @@ int parseconfigline(int entry, int lineno,char *line){
 
   // Is there space for another entry?
   if (entry>=MAXENTRIES){
-    printout(LOG_CRIT,"Error: configuration file %s can have no more than %d entries\n",
+    printout(LOG_CRIT,"Error: configuration file %s can have no more than MAXENTRIES=%d entries\n",
 	     CONFIGFILE,MAXENTRIES);
     exit(1);
   }
@@ -1131,7 +1134,10 @@ int parseconfigline(int entry, int lineno,char *line){
   cfg->trackatt=(unsigned char *)calloc(32,1);
   
   if (!cfg->name || !cfg->failatt || !cfg->trackatt) {
-    perror("no memory available to save name");
+    if (errno<sys_nerr)
+      printout(LOG_INFO,"No memory to store file: %s line %d, %s\n", CONFIGFILE, lineno, sys_errlist[errno]);
+    else
+      printout(LOG_INFO,"No memory to store file: %s line %d\n", CONFIGFILE, lineno);
     exit(1);
   }
 
@@ -1352,9 +1358,6 @@ void ParseOpts(int argc, char **argv){
       exit(0);
     }
   }
-  
-  // print header
-  printhead();
   return;
 }
 
@@ -1395,9 +1398,13 @@ int makeconfigentries(int num, char *name, int isata, int start){
     cfg->failatt=(unsigned char *)calloc(32,1);
     cfg->trackatt=(unsigned char *)calloc(32,1);
     if (!cfg->name || !cfg->failatt || !cfg->trackatt) {
-      perror("no memory available to save name");
+      if (errno<sys_nerr)
+	printout(LOG_INFO,"No memory for %d'th device after %s, %s\n", i, name, sys_errlist[errno]);
+      else
+	printout(LOG_INFO,"No memory for %d'th device after %s\n", i, name);
       exit(1);
     }
+
     // increment final character of the name
     cfg->name[strlen(name)-1]+=i;
   }
@@ -1435,13 +1442,16 @@ int main (int argc, char **argv){
   con->veryquietmode=debugmode?0:1;
   con->checksumfail=0;
 
-  // look in configuration file CONFIGFILE (normally /etc/smartd.conf)
-  entries=parseconfigfile();
-
   // If in background as a daemon, fork and close file descriptors
   if (!debugmode){
     daemon_init();
   }
+  
+  // print header after daemon_init so right process number in syslog
+  printhead();
+
+  // look in configuration file CONFIGFILE (normally /etc/smartd.conf)
+  entries=parseconfigfile();
 
   // setup signal handler for shutdown
   if (signal(SIGINT, sighandler)==SIG_IGN)
@@ -1454,7 +1464,6 @@ int main (int argc, char **argv){
     signal(SIGHUP, SIG_IGN);
   if (signal(SIGUSR1, sleephandler)==SIG_IGN)
     signal(SIGUSR1, SIG_IGN);
-
   
   // install goobye message
   atexit(goobye);
diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp
index 0e7336e9e0cb26af1c5b95d70e42dcf31316fa1c..05e68e20f0a29009f6a09e45b9acbac1ee4410c4 100644
--- a/sm5/smartd.cpp
+++ b/sm5/smartd.cpp
@@ -47,7 +47,7 @@
 
 // CVS ID strings
 extern const char *CVSid1, *CVSid2;
-const char *CVSid6="$Id: smartd.cpp,v 1.76 2002/11/25 11:45:28 ballen4705 Exp $" 
+const char *CVSid6="$Id: smartd.cpp,v 1.77 2002/12/01 06:48:14 ballen4705 Exp $" 
 CVSID1 CVSID2 CVSID3 CVSID4 CVSID7;
 
 // global variable used for control of printing, passing arguments, etc.
@@ -1090,7 +1090,10 @@ int parseconfigline(int entry, int lineno,char *line){
   static int numtokens=0;
 
   if (!(copy=strdup(line))){
-    perror("no memory available to parse line");
+    if (errno<sys_nerr)
+      printout(LOG_INFO,"No memory to parse file: %s line %d, %s\n", CONFIGFILE, lineno, sys_errlist[errno]);
+    else
+      printout(LOG_INFO,"No memory to parse file: %s line %d\n", CONFIGFILE, lineno);
     exit(1);
   }
   
@@ -1115,7 +1118,7 @@ int parseconfigline(int entry, int lineno,char *line){
 
   // Is there space for another entry?
   if (entry>=MAXENTRIES){
-    printout(LOG_CRIT,"Error: configuration file %s can have no more than %d entries\n",
+    printout(LOG_CRIT,"Error: configuration file %s can have no more than MAXENTRIES=%d entries\n",
 	     CONFIGFILE,MAXENTRIES);
     exit(1);
   }
@@ -1131,7 +1134,10 @@ int parseconfigline(int entry, int lineno,char *line){
   cfg->trackatt=(unsigned char *)calloc(32,1);
   
   if (!cfg->name || !cfg->failatt || !cfg->trackatt) {
-    perror("no memory available to save name");
+    if (errno<sys_nerr)
+      printout(LOG_INFO,"No memory to store file: %s line %d, %s\n", CONFIGFILE, lineno, sys_errlist[errno]);
+    else
+      printout(LOG_INFO,"No memory to store file: %s line %d\n", CONFIGFILE, lineno);
     exit(1);
   }
 
@@ -1352,9 +1358,6 @@ void ParseOpts(int argc, char **argv){
       exit(0);
     }
   }
-  
-  // print header
-  printhead();
   return;
 }
 
@@ -1395,9 +1398,13 @@ int makeconfigentries(int num, char *name, int isata, int start){
     cfg->failatt=(unsigned char *)calloc(32,1);
     cfg->trackatt=(unsigned char *)calloc(32,1);
     if (!cfg->name || !cfg->failatt || !cfg->trackatt) {
-      perror("no memory available to save name");
+      if (errno<sys_nerr)
+	printout(LOG_INFO,"No memory for %d'th device after %s, %s\n", i, name, sys_errlist[errno]);
+      else
+	printout(LOG_INFO,"No memory for %d'th device after %s\n", i, name);
       exit(1);
     }
+
     // increment final character of the name
     cfg->name[strlen(name)-1]+=i;
   }
@@ -1435,13 +1442,16 @@ int main (int argc, char **argv){
   con->veryquietmode=debugmode?0:1;
   con->checksumfail=0;
 
-  // look in configuration file CONFIGFILE (normally /etc/smartd.conf)
-  entries=parseconfigfile();
-
   // If in background as a daemon, fork and close file descriptors
   if (!debugmode){
     daemon_init();
   }
+  
+  // print header after daemon_init so right process number in syslog
+  printhead();
+
+  // look in configuration file CONFIGFILE (normally /etc/smartd.conf)
+  entries=parseconfigfile();
 
   // setup signal handler for shutdown
   if (signal(SIGINT, sighandler)==SIG_IGN)
@@ -1454,7 +1464,6 @@ int main (int argc, char **argv){
     signal(SIGHUP, SIG_IGN);
   if (signal(SIGUSR1, sleephandler)==SIG_IGN)
     signal(SIGUSR1, SIG_IGN);
-
   
   // install goobye message
   atexit(goobye);