fixup! mainloop: refactor signals to use a small helper function