multiple changes:

use `return' instead of `pthread_exit' to suppress false alarms in
valgrind
deal with POLLHUP to properly exit on Linux
replace all cpu_relax with sched_yield for the time being