5e24a77193
This commit uses a pthread mutex in shared memory to prevent almost all cases of multiple processes simultaneously reading/writing to device sysfs files. The main existing race condition is when 2 processes are starting at the same time, setting up their shared memory and mutexes. Since this is meant to prevent collisions among thread and processes, the small shared memory segments (big enough for a pthread_mutex) will persist until reboot.