[WIP] Added simple main loop with signal handlers

This is for #46.


The libev linkage is done somewhere different (but was forgotten). The fix is in PR #41. I'll merge that one, you can then rebase and remove the `-lev`.