Package: hddtemp
Version: 0.3-beta13-9
Severity: normal

When I start hddtemp over an ssh connection, the connection does not end
by the logout. It's stuck. Logging in again over a different session and
killing hddtemp solved the issue (as well as closing the terminal
window).

The problem is because hddtemp does not properly daemonize itself as
described in the UNIX Programming FAQ, 1.7:
http://www.faqs.org/faqs/unix-faq/programmer/faq/

An patch which fixes the problem is attached, note however that it's 
incomplete because the FAQ says you should establish new open
descriptors for stdin, stdout, sterr. Also, my three close statements
are probably redundant. At least one is necessary however. And moving
the daemon_open_sockets,openlog block is, I guess, also unnecessary. 

--- hddtemp-0.3-beta13.orig/src/daemon.c
+++ hddtemp-0.3-beta13/src/daemon.c
@@ -268,11 +268,17 @@
   fd_set             deffds;
   time_t             next_time;
 
-  if (tcp_daemon)
-    daemon_open_sockets();
-  
-  if (syslog_interval > 0)
-    openlog("hddtemp", LOG_PID, LOG_DAEMON);
+  switch(fork()) {
+  case -1:
+    perror("fork");
+    exit(2);
+    break;
+  case 0:
+    setsid();
+    break;
+  default:
+    exit(0);
+  }
 
   switch(fork()) {
   case -1:
@@ -285,6 +291,18 @@
     exit(0);
   }
 
+  close(0);
+  close(1);
+  close(2);
+
+  if (tcp_daemon)
+    daemon_open_sockets();
+  
+  if (syslog_interval > 0)
+    openlog("hddtemp", LOG_PID, LOG_DAEMON);
+
+
+
   /* close standard input and output */
   for(i = 0; i < 3; i++) {  
     for (j = 0 ; j < sks_serv_num ; j++)





-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.10-1-686
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages hddtemp depends on:
ii  debconf [debconf-2.0]       1.4.30.13    Debian configuration management sy
ii  grep                        2.5.1.ds1-4  GNU grep, egrep and fgrep
ii  libc6                       2.3.2.ds1-21 GNU C Library: Shared libraries an
ii  sed                         4.1.2-8      The GNU sed stream editor

-- debconf information excluded


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to