iv_thread: Create threads joinable, and wait for them on exit.
iv_thread: Create threads joinable, and wait for them on exit.

This allows the creating thread to track the lifetimes of created
pthread_t handles, which:

- is necessary if we ever want to provide iv_thread_kill(),
  as pthread_kill() on a pthread_t for which the corresponding
  (detached) thread has already exited is undefined; and

- has the nice side effect of shutting up valgrind about memory
  leaks on exit if we terminate the process after a thread has
  signaled its creator of its demise but before it has had a
  chance to run its other (thread library level) cleanup code.

Signed-off-by: Lennert Buytenhek <8858498612e3a522354216649776e3032dcb7e5b@wantstofly.org>

buytenh/ivykis,buytenh/ivykis