Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition on non root user when PiPiper::Pin.new #92

Open
hugueslamy opened this issue Sep 11, 2018 · 1 comment
Open

Race condition on non root user when PiPiper::Pin.new #92

hugueslamy opened this issue Sep 11, 2018 · 1 comment

Comments

@hugueslamy
Copy link

Working on a Raspberry Pi 2 on Raspian Stretch, I end up with a weird error.
Errno::EACCES: Permission denied @ rb_sysopen - /sys/class/gpio/gpio16/direction

My setup worked couple of time the day before but not anymore. I dig many whatever.overflow to find some help.

My understanding so far. When you write to the export file, a small directory of file is created automatically. I don't know the process that does it, but it happen when you send echo "16" > export
The gpio16 directory is created with a bunch of file. One of them is the direction file. From what I understand the process (again I don't know which one) create it as root/root and launch a chown to make it root/gpio. Instant after the PiPiper::BCM2835 file write the direction file and this conflict with the direction file being root/root.

A was able to solve this by inserting a sleep(0.1) on line 61 of the file lib/pi_piper/bcm2835.rb
Not the most elegant, but get the job done.

As a much better solution I see 3 ways,

  1. This sleep
  2. A catch of the Errno::EACCES error with a retry
  3. Modify the setting of the process creating the direction to set the proper user/group right away

A also recompile the .SO file to the latest version and this help on some other permission issues

I'm just the application guy and most likely people used to low level programming are much better at solving this than me.

@elmatou
Copy link
Contributor

elmatou commented Jun 5, 2019

Thank you for the tip (9 months later) you saved my day !!

I'm going to adress this issue my PiPiper spin off : https://github.com/elmatou/rpio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants