Trying to run the pigpio example program freq_count_1 I get the error Can't lock /var/run/pigpio.pid. The gpiotest program, however, runs as expected. Below you can see what I did. I have a Raspberry Pi 2 running Jessie.

gcc -Wall -pthread -o freq_count_1 freq_count_1.c -lpigpio -lrt`
rm -f /var/run/pigpiod.pid`
./freq_count_1 4 7 -r2 -s2`
  • Monitoring GPIO pins: 4 and 7
  • Sample rate 2: micros
  • refresh rate 2 deciseconds

2015-11-27 13:47:24 initInitialise: Can't lock /var/run/pigpio.pid

  • I'm getting this problem when killing my program ungracefully. It seems the missing gpioTerminate() call in the end causes a file lock not to get unlocked or so. Don't have a fix yet, do you? Mar 23, 2016 at 15:46

2 Answers 2


You need to stop the pigpio daemon if you run a program directly linked with the pigpio C library.

In effect your program becomes the pigpio daemon and only one may be running at a time.


sudo killall pigpiod

Then run your C program.

While your C program is running it acts as the daemon, so you can still run gpiotest and any of the pigs commands, e.g. pigs pigpv (software version), pigs hwver (hardware version), pigs t (current tick).

  • Many thanks for a rapid and clear answer that did the trick.
    – user37342
    Nov 27, 2015 at 13:17

You need to find out which other process is using it. Then kill that process.

This issue is documented on the FAQ page linked below:


  • The command ps aux | grep pigpiodcan be replaced with pgrep pigpiod
    – MatsK
    Mar 6, 2019 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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