是否可以向属于不同用户的进程发送信号?

Art*_*yom 4 linux posix signals

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

例如

PID   user   group
1234  foo    foobar   
4321  bar    foobar
Run Code Online (Sandbox Code Playgroud)

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

如果我使用插座或管道,我可以设置他们的面具rw-rw-r--,通信将工作.但是我需要使用信号进行通信(普通或实时,不重要).

有办法吗?

Kam*_*rot 7

引用来自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.
Run Code Online (Sandbox Code Playgroud)

您可以找到有用的功能(7)和setcap(8).

  • @Artyom 唯一的其他方法似乎是在同一个 uid 下运行两个应用程序 (2认同)