static TidStatus *g_tid_status;
static int g_all_tid_num;
-#define MAX_SIG_WAIT_TIME 5000 // times 2 ms thats 10 seconds
+#define MAX_SIG_WAIT_TIME 10000 // times 2 ms thats 20 seconds
// Hackish, based on glibc's definition in sysdeps/unix/sysv/linux/nptl-signals.h
#define SIGSETXID (__SIGRTMIN + 1)
g_tid_status[tid_index++].tid = *it;
if (Syscall::tgkill(cur_pid, *it, SIGSETXID) < 0) {
- const auto err = errno;
+ auto err = errno;
+
+ if (EAGAIN == err) { // resource temporarily unavailable, trying again
+ LogWarning("Received EAGAIN from tgkill, will wait 2 ms & try again");
+ usleep(2000); // 2 ms
+ if (Syscall::tgkill(cur_pid, *it, SIGSETXID) < 0) {
+ err = errno;
+ } else {
+ ++it;
+ continue;
+ }
+ }
if (ESRCH == err) { // thread already gone
threads_gone++;
g_tid_status[tid_index-1].status = TID_STATUS_DEAD;