7

我需要向不同的进程发送信号以进行一些实时通信,但是该进程属于不同的用户。

例如

PID   user   group
1234  foo    foobar   
4321  bar    foobar

我希望进程 1234 和 4321 能够相互发送信号吗?

如果我使用套接字或管道,我可以将它们的掩码设置为rw-rw-r--并且通信将起作用。但是我需要使用信号(普通或实时,不重要)进行通信。

有没有办法做到这一点?

4

1 回答 1

9

引用 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.

您会发现 capabilities(7) 和 setcap(8) 很有用。

于 2012-11-11T20:22:09.840 回答