Update work loop to use polling.

This allows signal handlers to work and makes it possible to have a
canWork() method.