When using rthreads, the thread that calls exit will be the last one to actually exit. This means that the main thread will exit and free the process group, which results in the thread dereferencing a null pointer when it is woken back up. Avoid this by checking that the ps_pgrp is not null before deferefencing it. Also expand the ps_session macro to avoid hiding the dereference.
When using rthreads, the thread that calls exit will be the last one to
actually exit. This means that the main thread will exit and free the
process group, which results in the thread dereferencing a null pointer
when it is woken back up. Avoid this by checking that the ps_pgrp is not
null before deferefencing it. Also expand the ps_session macro to avoid
hiding the dereference.

ok tedu@

orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars