Linux file write succeeds 1st time errors on 2nd try

26 Views Asked by At

I have a small C++ program that writes a PWM period value to the following file on the BeagleBone Black:

/sys/class/pwm/pwmchip5/pwm0/period

The first time the program runs the file write succeeds. The file is opened with the O_WRONLY and O_NONBLOCK flags. The program closes the file descriptor before exiting.

When I invoke the program a 2nd time, the write fails.

I tried to write a value into the file afterwards with 'echo' on the command line but that fails too.

If I reboot the board then I can run the program and it succeeds (the 1st time again).

Is the file somehow being locked after the first run of the program?

0

There are 0 best solutions below