zfsonlinux/zfs — pull request #991 by dechamps (2012-09-27 12:44:01+00:00)
Title: Create threads in detached state in userspace

Currently, `thread_create()`, when called in userspace, creates a joinable (i.e. not detached thread). This is the pthread default.

Unfortunately, this does not reproduce kthreads behavior (kthreads are always detached). In addition, this contradicts the original Solaris code which creates userspace threads in detached mode.

These joinable threads are never joined, which leads to a leakage of pthread thread objects ("zombie threads"). This in turn results in excessive ressource consumption, and possible ressource exhaustion in extreme cases (e.g. long ztest runs).

This patch fixes the issue by creating userspace threads in detached mode. The only exception is ztest worker threads which are meant to be joinable.

See issue #989.