sysfs: pause briefly to allow udev rules to apply when exporting PWMPin

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-12-20 07:05:10 +01:00
parent 298b175108
commit 1dc8de699c
1 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"os" "os"
"strconv" "strconv"
"syscall" "syscall"
"time"
) )
// PWMPin is the interface for sysfs PWM interactions // 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 return nil
} }