c - kill a specific thread in GDB -
i want kill specific thread in gdb. how attach program gdb.
(gdb) r ./bin/myprog arg1 arg2
i current running threads by
(gdb) info threads 3 thread 0x7ffff61fe700 (lwp 28549) 0x000000323b6db7ad in foo () /lib64/libc.so.6 * 2 thread 0x7ffff6bff700 (lwp 28548) bar () @ ./src/myprog.c:229 1 thread 0x7ffff7506740 (lwp 28547) 0x000000323be0822d in pthread_join () /lib64/libpthread.so.0
this how tried kill thread (say thread 3)
(gdb)t 3 [switching thread 3 (thread 0x7ffff61fe700 (lwp 28549))]#0 foo () @ ./src/myprog.c:288 (gdb)call raise(3,0)
here assumed signature of raise
raise(threadid displayed in gdb, signo 0)
but thread not getting killed. should use different signo
or thread id wrong?
note: read this question in did not me
signal handling in multithreaded apps complicated. thus, makes more sense switch thread, make sure not holding resources (such locked mutexes) , invoke pthread_exit()
on behalf if exited on own accord.
Comments
Post a Comment