Switch to using the sighandlers table to determine whether a sighandler is entered.

This is a nontrivial part of #329 that deserves its own commit.  Also packs in an unrelated util.c cleanup.