Note that in addition to checking if b2g is running and rebooting if it is, this also introduces a 2 second sleep (as suggested at [1]). I wonder if just adding that sleep, without the extra logic would accomplish the same thing?

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=971747#c26