From 1dc8de699c94910e73901d0b392e64ea5ba2d7dc Mon Sep 17 00:00:00 2001 From: deadprogram Date: Wed, 20 Dec 2017 07:05:10 +0100 Subject: [PATCH] sysfs: pause briefly to allow udev rules to apply when exporting PWMPin Signed-off-by: deadprogram --- sysfs/pwm_pin.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysfs/pwm_pin.go b/sysfs/pwm_pin.go index c3d56093..5747aded 100644 --- a/sysfs/pwm_pin.go +++ b/sysfs/pwm_pin.go @@ -6,6 +6,7 @@ import ( "os" "strconv" "syscall" + "time" ) // PWMPin is the interface for sysfs PWM interactions @@ -65,6 +66,11 @@ func (p *PWMPin) Export() error { } } + // Pause to avoid race condition in case there is any udev rule + // that changes file permissions on newly exported PWMPin. This + // is a common circumstance when running as a non-root user. + time.Sleep(100 * time.Millisecond) + return nil }