开发者

Can't compile a program that calls tgkill

开发者 https://www.devze.com 2023-02-18 12:17 出处:网络
I\'m trying to write a program that uses tgkill to send a signal to a specific thread, but 开发者_如何学运维whenever I compile it with gcc I get an error about an undefined reference to \'tgkill\'. I

I'm trying to write a program that uses tgkill to send a signal to a specific thread, but 开发者_如何学运维whenever I compile it with gcc I get an error about an undefined reference to 'tgkill'. I tried compiling with -lpthread but it didn't help. I've googled and googled and can't come up with any answers. How do I get it to compile??


From the tgkill() manpage:

Glibc does not provide wrappers for these system calls; call them using syscall(2).


You might want to use something like this instead.

tgid=getpid();  
tid=gettid();  
syscall(SYS_tgkill, tgid, tid, signalname));


As noted in another answer, glibc does not provide wrappers for tkill() or tgkill().

Instead, you're supposed to use pthread_kill().

0

精彩评论

暂无评论...
验证码 换一张
取 消