How To Apply The Patch Detailed In SorceForge Ticket #315


This ticket describes how to patch a file to fix a race condition hang in LIRC 0.10.1.  However, it does not explain how to apply the patch to an existing installation of LIRC.  If you don’t know what LIRC is then click here.  The ticket describes a problem when multiple commands are sent in quick succession.  The first 2 are sent just fine, but the software hangs on the third.  Full details on the symptoms can be found in the ticket.

My approach to applying the patch was to fire up a development Pi (actually a Zero as that is what the application runs on, but I would suggest using the same model as your application runs on).  Then download the LIRC sources and then patch and rebuild the software.  This was a little tricky as the Raspberry Pi installation of LIRC does not use a standard configuration.

Development Pi Initial Conditions

  • Pi Version: Pi Zero W
  • Operating System:
    • PRETTY_NAME=”Raspbian GNU/Linux 10 (buster)”
    • NAME=”Raspbian GNU/Linux”VERSION_ID=”10″
    • VERSION=”10 (buster)”
    • ID=raspbian

Target Pi Initial Conditions

  • LIRC Version: 0.10.1

Required Software

The source code and patch file are required, and in case they should disappear from the web I have made them available on my site.  To get them log in to your development Pi and do the following:

  • cd /home/pi
  • wget
  • wget
  • tar -xjvf lirc-0.10.1.tar.bz2
  • mv 0003-lirc-315-irsend-lircd-hang-when-using-repeats.patch lirc-0.10.1/
  • cd lirc-0.10.1


Before you can successfully build the sources a number of packages are required.  You may already have some of them, but no harm will occur if you try to load them again.  The packages from man2html on probably are not needed and can be skipped.  Some install quite a lot of stuff, particularly man2hmtl which appears to install apache2.  I have not tested if you can leave them out.  Anyway, do the following:

  • sudo apt-get install git
  • sudo apt-get install libtool
  • sudo apt-get install kmod
  • sudo apt-get install pkg-config
  • sudo apt-get install raspberrypi-kernel-headers
  • sudo apt-get install xsltproc
  • sudo apt-get install python3-yaml
  • sudo apt-get install man2html
  • sudo apt-get install doxygen
  • sudo apt-get install python3-gi

Applying the patch

Git can apply the patch file for you.  I suggest making a backup of the file to be patched.  Follow these steps.  You should already be in the lirc-0.10.1 folder:

  • pushd daemons
  • cp lircd.cpp lircd.cpp.original
  • popd
  • git apply 0003-lirc-315-irsend-lircd-hang-when-using-repeats.patch
  • diff daemons/lircd.cpp.original daemons/lircd.cpp | less

The last command will display the differences between the original file and the patched version.  If it shows no difference you did not apply it correctly.  Press Q to return to the prompt.  Check your work!

Building The Source

During the build process you will see a number of warnings.  Don’t be concerned.  These steps will take a while, particularly on a Zero. Do the following:

  • mkdir _build
  • cd _build
  • ../configure ––prefix=/usr ––sysconfdir=/etc
  • make

If all goes well you should have the following file. To check that you do:

  • cd daemons/.lib
  • ls -la lircd

On my system this resulted in
-rwxr-xr-x 1 pi pi 292972 Nov 10 13:59 lircd

Installing The patched Executable

The file listed above must be sent to the target Pi with LIRC already installed.  It goes in /usr/sbin.  I am assuming here that you have ssh installed on both systems.  If not, run raspi-config to enable it.  Here are the steps.  The rsync step will request you target Pi password for user pi:

First log into the target Pi, then

  • sudo su – root
  • cd /usr/sbin
  • cp lircd lircd.original
  • systemctl stop lircd
  • rsync -ve ssh pi@<ip of development pi>:/home/pi/lirc-0.10.1/_build/daemons/.lib/lircd .
  • ls -la /usr/sbin/lircd*

The last command should result in a listing similar to:
-rwxr-xr-x 1 root root 292972 Nov 10 17:20 /usr/sbin/lircd
-rwxr-xr-x 1 root root 46620 Nov 10 13:54 /usr/sbin/lircd.original
If not check your work.  The lircd file should have the same size as the listed in the previous section.

If all is well then do the following to adjust the service and restart it with:

  • sudo nano /lib/systemd/system/lircd.service
    and change the line
    and save with  ^X, Y and enter
  • systemctl daemon-reload
  • systemctl start lircd

Then test your system with:

  • irsend send_once <your code file name> <1> <2> <3> <4>

where your code file name is the name defined in your conf file in /etc/lirc/lircd.conf.d/.  Mine is QIP7232-2.  <1> … <4> should be replaced by valid commands for that remote.  The irsend command should send all 4 commands and then return to the prompt.  If not check your work!  But if it does then the patch has been applied successfully.


These notes are based on my recent investigation of the process of applying the patch.  I have not gone through these steps to confirm that they are all correct.  However, they should get you a long way towards success.  Remember, this will only patch LIRC V0.10.1 and may not be required on subsequent versions.

To view my page describing the building of Node-Red project to simulate a FIOS Remote Control click here.

Good Luck!

Share This