我需要向不同的进程发送信号以进行一些实时通信,但是该进程属于不同的用户.
例如
PID user group
1234 foo foobar
4321 bar foobar
我希望进程1234和4321能够相互发送信号吗?
如果我使用套接字或管道,我可以将它们的掩码设置为rw-rw-r–并且通信可以正常工作.但是我需要使用信号进行通信(普通或实时,不重要).
有办法吗?
解决方法:
引用来自kill(2):
For a process to have permission to send a signal it must either be privileged
(under Linux: have the CAP_KILL capability), or the real or effective user ID
of the sending process must equal the real or saved set-user-ID of the target
process. In the case of SIGCONT it suffices when the sending and receiving
processes belong to the same session.
您可以找到有用的功能(7)和setcap(8).
标签:linux,posix,signals
来源: https://codeday.me/bug/20190826/1725592.html