Skip to content

Commit f82ba3a

Browse files
committed
close enable_fd when stopping PWM output (#197)
Issue #197: JesseMcL raised the issue that running PWM.start() and PWM.start() in a loop will eventually exhaust the number of open file descriptors and PWM.start() will raise the error: RuntimeError: problem with sysfs file. The file descriptor for the enable file should be closed in pwm_disable() to avoid the leak Signed-off-by: Drew Fustini <[email protected]>
1 parent fff7617 commit f82ba3a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

source/c_pwm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,9 @@ BBIO_err pwm_disable(const char *key)
717717
#endif
718718

719719
//close the fd
720+
#ifdef BBBVERSION41
721+
close(pwm->enable_fd);
722+
#endif
720723
close(pwm->period_fd);
721724
close(pwm->duty_fd);
722725
close(pwm->polarity_fd);

0 commit comments

Comments
 (0)