oyss
oyss

Reputation: 692

pthread_kill returns error number 11

I have a thread currently stopped by pselect

(void)pselect(1, NULL, NULL, NULL, NULL, &select_mask);

the sigmask is initialized this way.

(void)sigfillset(&select_mask);
(void)sigdelset(&select_mask, 37);

debug in gdb

4 Thread 0x7ffff7fce710 (LWP 28287)  0x00007ffff6a24dab in pselect () from ./libc.so.6

When i try to to send signal number 37 to this thread to get it out from pselect. It returns 11.

(gdb) call pthread_kill(0x7ffff7fce710,37)
$26 = 11

trying other signals will return 0,because other signals are supposed to be blocked.

(gdb) call pthread_kill(0x7ffff7fce710,3)
$27 = 0

what is 11 means here? EAGAIN? And how to get rid of it and end that pselect?

I'm using 64bit suselinux 11 system.

Upvotes: 2

Views: 1459

Answers (2)

pilcrow
pilcrow

Reputation: 58524

EAGAIN is an undocumented Linux return code for pthread_kill() (implemented in terms of tgkill() on Linux) meaning that the receiving real-time signal queue has overflowed.

My guess is that you've masked off the signal and sent thousands of it before the call to pselect(). On my system I observe this behavior compiling with -pthread and sending just over 15202 instances of a real-time signal.

Upvotes: 2

Smurker
Smurker

Reputation: 714

Catch the return value of pthread_kill and run it through the strerror function. You'll get a string returned with the error specified.

if ((error = pthread_kill(...)) != 0)
    printf("pthread_kill error: %s\n", strerror(error));

Also, while trying to simulate what you're doing, i ran into a similar issue. My solution was to simply use info threads and raise, like so

(gdb) info threads
  2 thread 1024621  thread () at main.c:7
* 1 thread 1025084  0x0fda2445 in _thread_sys___thrsleep () from /usr/lib/libc.so.65.0
(gdb) call raise(1, 37)
$1 = 0
(gdb) detach

Upvotes: 2

Related Questions