Don't use signal-unsafe longjmp in signal handler

This uses the method suggested by Leandro in
https://github.com/lpereira/lwan/issues/58 to close the main socket in
the signal handler and check for EBADF to break out of the main loop.

Fixes #58
And initialize `main_socket` to -1 here again?