Problem: don't know when system is sleeping
The segfault described by c623d0daeb8ffb3675a606c7912ccf450e6034b161dc5aab099c0d58e927f629 happens when the system goes to sleep.
There's nothing we can really do about it unless we know when the system is going to sleep.
Solution: use a C library to detect system sleep.