Fix pthread_detach for already-exited threads.

This fix handles the case when pthread_detach is
called for threads which have already exited.
This is required to avoid any memory leak

Change-Id: I2bf7f41234d93b226132a4c51705f4186f4961c3
Reported-by: Paresh Nakhe <pnakhe@codeaurora.org>
Merge branch 'cm-11.0' of git://github.com/CyanogenMod/android_bionic into cm-11.0