I'm not on Linux, so no way to check what happens there with my own
programmes. You might want to post a reduced programme that demonstrates
the flashing so that people can attempt to track it down and hopefully come
up with a solution.
Enjoy,
Mike