0

I'm debugging lirc on a Pi 3b running Stretch with 4.19 kernel.

In my previous question, I found a way to cause lircd to function, but it requires invoking the daemon with passed parameters.

I need to start lircd like this:

sudo lircd --device /dev/lirc0

Now I want to cause the Pi to boot with lirc in a usable state, using those required parameters in init.d.

The "start-stop-daemon" section of the file "lircd" in /etc/init.d looks like this:

        start-stop-daemon --start --quiet --oknodo \
                --exec /usr/sbin/lircd -- < /dev/null

When the Pi boots, lircd is already running, so to allow irsend to function I have to issue these commands to kill and restart with the required parameters:

sudo pkill -SIGTERM  lircd
sudo lircd --device /dev/lirc0

The Man page for start-stop-daemon --start says:

"Any arguments given after -- on the command line are passed unmodified to the program being started."

I edited the "start-stop-daemon" line of the "start" case section in the file "lircd" in /etc/init.d to this:

        start-stop-daemon --start --quiet --oknodo \
                --exec /usr/sbin/lircd  -- --device /dev/lirc0 < /dev/null

Based on the Man page for start-stop-daemon, I'm interpreting this command in its unmodified state as passing "< /dev/null" to lircd when it is run. That is the string that is after "--".

My expectation is that after my edit, the string "--device /dev/lirc0 < /dev/null" will be passed as parameters to /usr/sbin/lircd when it is run.

However, it does not work. irsend does not function at startup, until the kill and re-run commands are given. I'm assuming the parameters are not passed to lircd, but I'm not sure why.

I am not sure why the original parameters after "--" redirect /dev/null to stdin. Why is that needed? Maybe that is sending my added parameters to /dev/null too? What would be the proper syntax to pass the required parameters?

2

The IO redirection is not a argument. You can see that with a script:

#!/bin/bash
i=0
while [ "$1" != "" ] ; do
    i=$((i+1))
    echo "$i:  $1"
    shift
done

If you execute this with ./script a b </dev/null, the output will be

a
b

So the shell that executes the script does the IO redirection for start-stop-daemon.

If you put quotes around the </dev/null, it will be passed as a argument. But then, start-stop-daemon will also pass it to lircd as a argument and not as an IO redirection.

The question is: why do you need a </dev/null when you start-up lircd? I have never needed to do that.

| improve this answer | |
  • I have no idea why </dev/null is needed. It was put there by the installer for lirc. I left it because I didn't understand why it was needed either, but it must be for a reason? ;-) – tim11g Feb 13 at 17:15
1

You are using Raspbian Stretch that already comes with systemd that replaces the old style SysV init system, managed with files in /etc/init.d/. This is deprecated since years and only emulated by systemd to ensure limited downstream compatibility. Have a look at Compatibility with SysV.

That you run into problems with sophisticated modifications of init scripts is not a surprise. You should really consider to use Unit files from systemd to manage services. If you really want to continue with init scripts then you should look at man systemd-sysv-generator what it does with your init scripts and why it doesn't work as expected.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.