Skip to content

Commit

Permalink
sysfs: pause briefly to allow udev rules to apply when exporting PWMPin
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Dec 20, 2017
1 parent 298b175 commit 1dc8de6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sysfs/pwm_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"strconv"
"syscall"
"time"
)

// PWMPin is the interface for sysfs PWM interactions
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 1dc8de6

Please sign in to comment.