Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to send a signal to process that belongs to different user?

I need to send a signal to different process for some real-time communication, however the process belongs to different user.

For example

PID   user   group
1234  foo    foobar   
4321  bar    foobar

I want process 1234 and 4321 to be able to send signals to each other?

If I was using sockets or pipes I could set their mask to rw-rw-r-- and communication would work. However I need to do the communication using signals (ordinary or real time, not important).

Is there a way to do it?

like image 275
Artyom Avatar asked Nov 11 '12 20:11

Artyom


People also ask

Can a process send a signal to itself?

A process can use kill() to send a signal to itself. If the signal is not blocked or ignored, at least one pending unblocked signal is delivered to the sender before kill() returns. If there are no other pending unblocked signals, the delivered signal is sig.

What command can be used to send signals to control processes?

The kill command in UNIX enables the user to send a signal to a process. A signal is a message sent to a process to interrupt it and cause a response. If the process has been designed to respond to signals of the type sent it does so; otherwise, it terminates.

Can a process kill another process?

Any process that has process ID of another process with same user-id can terminate it by sending a SIGQUIT signal to that process using kill(pid, SIGQUIT) .


1 Answers

Quote from 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.

You can find capabilities(7) and setcap(8) useful.

like image 71
Kamil Šrot Avatar answered Sep 22 '22 10:09

Kamil Šrot