On Thu, Feb 25, 2010 at 02:48:26PM +0100, Guus Sliepen wrote:
> two daemons at the same time. In your case, the original lircd can also read
> input device files. This requires a bit more effort, and you should look at

Good hint, thanks.

> I'll also see if I can add some logic to inputlircd to detect if another lirc
> daemon is still running, and exit with a warning.

That would be great.

        fuser /dev/lircd
could do the trick: it returns 0 if the socket exists and is in use, and
1 if the socket does not exist or is not in use.

Small patch attached. A little bit dirty, but it works :) It does not
work if somebody configures -d in /etc/default/inputlirc to a different
socket name - parsing things like
        -d /dev/foo/bar
        -c -d /dev/foo/bar -f
        -cd /dev/foo/bar -f
in shell is not that nice - works, but ... :)


regards
   Mario
-- 
It is a capital mistake to theorize before one has data.
Insensibly one begins to twist facts to suit theories instead of theories
to suit facts.                   -- Sherlock Holmes by Arthur Conan Doyle
--- /etc/init.d/inputlirc.orig	2009-07-29 16:41:47.000000000 +0200
+++ /etc/init.d/inputlirc	2010-02-25 15:34:36.000000000 +0100
@@ -18,9 +18,18 @@
 
 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
+check_lircd() {
+    if fuser -s /dev/lircd 2>/dev/null; then
+	echo "Warning: Some other process is already using /dev/lircd" >&2
+	#exit 1		# better but requires special handling in postinst
+	exit 0
+    fi
+}
+
 case "$1" in
   start)
     echo "Starting $DESC"
+    check_lircd
     start-stop-daemon --exec $DAEMON --start -- $OPTIONS $EVENTS
   ;;
   stop)
@@ -30,6 +39,7 @@
   restart|reload|force-reload)
     echo "Restarting $DESC configuration"
     start-stop-daemon --exec $DAEMON --stop 
+    check_lircd
     start-stop-daemon --exec $DAEMON --start -- $OPTIONS $EVENTS
   ;;
   *)

Attachment: signature.asc
Description: Digital signature

Reply via email to