fix setgroups behavior in multithreaded process