--- Begin Message ---
Package: hddtemp
Version: 0.3-beta15-12
Severity: wishlist
Tags: patch
Hi,
it would be nice to be able to run the hddtemp daemon under a process
supervisor such as runit, daemontools or daemon.
I added a -F command line switch that causes hddtemp to stay in the
foreground even in daemon mode to facilitate this.
Please apply my attached patch.
Thanks
Andras
-- System Information:
Debian Release: unstable
APT prefers dapper-updates
APT policy: (1200, 'dapper-updates'), (1200, 'dapper-security'), (1200,
'dapper'), (1200, 'breezy-security'), (1200, 'breezy'), (100, 'experimental'),
(100, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16.10+skasv3pre9-chardonnay-skas3-v9-pre9
Locale: LANG=C, LC_CTYPE=hu_HU (charmap=ISO-8859-2)
Versions of packages hddtemp depends on:
ii debconf [debconf-2.0] 1.5.0 Debian configuration management sy
ii grep 2.5.1.ds2-4 GNU grep, egrep and fgrep
ii libc6 2.3.6-15 GNU C Library: Shared libraries
ii sed 4.1.4-4 The GNU sed stream editor
hddtemp recommends no packages.
-- debconf information excluded
--
Andras Korn <korn at chardonnay.math.bme.hu>
<http://chardonnay.math.bme.hu/~korn/> QOTD:
Everything is fine with the world - one mile under ground.
diff -ur hddtemp-0.3-beta15/doc/hddtemp.8
hddtemp-0.3-beta15+foreground/doc/hddtemp.8
--- hddtemp-0.3-beta15/doc/hddtemp.8 2006-06-21 12:18:51.940989511 +0200
+++ hddtemp-0.3-beta15+foreground/doc/hddtemp.8 2006-06-21 12:19:15.888615926
+0200
@@ -80,6 +80,10 @@
.B \-q, \-\-quiet
Don't check if the drive is supported.
.TP
+.B \-F, \-\-foreground
+Don't fork into the background even in daemon mode. This is useful
+when running under a process supervisor.
+.TP
.B \-v, \-\-version
Display hddtemp version number.
.TP
diff -ur hddtemp-0.3-beta15/src/daemon.c
hddtemp-0.3-beta15+foreground/src/daemon.c
--- hddtemp-0.3-beta15/src/daemon.c 2006-06-21 12:18:51.940989511 +0200
+++ hddtemp-0.3-beta15+foreground/src/daemon.c 2006-06-21 12:19:07.124752634
+0200
@@ -273,28 +273,30 @@
fd_set deffds;
time_t next_time;
- switch(fork()) {
- case -1:
- perror("fork");
- exit(2);
- break;
- case 0:
- break;
- default:
- exit(0);
- }
-
- setsid();
-
- switch(fork()) {
- case -1:
- perror("fork");
- exit(2);
- break;
- case 0:
- break;
- default:
- exit(0);
+ if (!foreground) {
+ switch(fork()) {
+ case -1:
+ perror("fork");
+ exit(2);
+ break;
+ case 0:
+ break;
+ default:
+ exit(0);
+ }
+
+ setsid();
+
+ switch(fork()) {
+ case -1:
+ perror("fork");
+ exit(2);
+ break;
+ case 0:
+ break;
+ default:
+ exit(0);
+ }
}
chdir("/");
umask(0);
diff -ur hddtemp-0.3-beta15/src/hddtemp.c
hddtemp-0.3-beta15+foreground/src/hddtemp.c
--- hddtemp-0.3-beta15/src/hddtemp.c 2006-04-19 04:37:35.000000000 +0200
+++ hddtemp-0.3-beta15+foreground/src/hddtemp.c 2006-06-21 12:19:01.760836310
+0200
@@ -75,7 +75,7 @@
char separator = SEPARATOR;
struct bustype * bus[BUS_TYPE_MAX];
-int tcp_daemon, debug, quiet, numeric, wakeup, af_hint;
+int tcp_daemon, debug, quiet, numeric, wakeup, af_hint,
foreground;
static enum { DEFAULT, CELSIUS, FAHRENHEIT } unit;
@@ -279,7 +279,7 @@
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- show_db = debug = numeric = quiet = wakeup = af_hint = syslog_interval = 0;
+ show_db = debug = numeric = quiet = wakeup = af_hint = syslog_interval =
foreground = 0;
unit = DEFAULT;
portnum = PORT_NUMBER;
listen_addr = NULL;
@@ -302,10 +302,11 @@
{"unit", 1, NULL, 'u'},
{"syslog", 1, NULL, 'S'},
{"wake-up", 0, NULL, 'w'},
+ {"foreground", 0, NULL, 'F'},
{0, 0, 0, 0}
};
- c = getopt_long (argc, argv, "bDdf:l:hp:qs:u:vnw46S:", long_options,
&lindex);
+ c = getopt_long (argc, argv, "bDdf:l:hp:qs:u:vnw46FS:", long_options,
&lindex);
if (c == -1)
break;
@@ -391,6 +392,7 @@
" -q --quiet : do not check if the drive is
supported.\n"
" -v --version : display hddtemp version number.\n"
" -w --wake-up : wake-up the drive if need.\n"
+ " -F --foreground : don't daemonize. Stay in
foreground.\n"
" -4 : listen on IPv4 sockets only.\n"
" -6 : listen on IPv6 sockets only.\n"
"\n"
@@ -406,6 +408,9 @@
case 'w':
wakeup = 1;
break;
+ case 'F':
+ foreground = 1;
+ break;
case 'S':
{
char *end = NULL;
diff -ur hddtemp-0.3-beta15/src/hddtemp.h
hddtemp-0.3-beta15+foreground/src/hddtemp.h
--- hddtemp-0.3-beta15/src/hddtemp.h 2006-04-19 04:40:11.000000000 +0200
+++ hddtemp-0.3-beta15+foreground/src/hddtemp.h 2006-06-21 12:19:01.760836310
+0200
@@ -78,7 +78,7 @@
extern struct bustype * bus[BUS_TYPE_MAX];
extern char errormsg[MAX_ERRORMSG_SIZE];
-extern int tcp_daemon, debug, quiet, wakeup, af_hint;
+extern int tcp_daemon, debug, quiet, wakeup, af_hint,
foreground;
extern char separator;
extern long portnum, syslog_interval;
extern char * listen_addr;
--- End Message ---