Improve threads' privilege synchronisation
* Drop the caps after the threads have been listed for a second time
(after the sync). This is to avoid errors during accessing /proc for
newly spawned threads as a unprivileged process.
* Check if newly spawned threads have correct labels.
* Retry the privileges sync twice for all remaining privileged threads.
* Retry listing of /proc/self/task/ in case of failure.
* Use set instead of vector for easier tid checks.
* Omit main thread from the list.
Change-Id: I21e7e5dd3d5efb70fe51a1597bd7bc4ccf1099e8