Richard Wolf <richard@nsotsupdaemnt.usyd.edu.au> wrote:
Hi
I’m trying to write a monitor process, the purpose of which is to receive
heartbeats from other processes, and restart them if they fail. The monitor
is a resource manager. I tried to use Pulses and MsgSendPulse as the
heartbeat mechanism, but this failed because the sending process had
insufficient permissions. Running the sending process as root solved the
problem.
It seems that a process must be running as root to be allowed to send
pulses to other processes running as root.
Is this correct? If yes, is there anything a resource manager can do to
allow clients to send them pulses?
Yes, this is correct. The docs for MsgSendPulse() are a bit odd…
You can send a pulse to any process in your process group if you
have the appropriate permissions to drop a signal on another process
(permission checking is identical to the checking used by the
kill() function).
The oddity is the bit about process groups – ignore that bit, but the
rest essentially says the rules are the same as for signals. Of course,
the rules for signals:
– you can send to processes with your own pid (that you own)
– root can send to processes with any pid
I couldn’t find any documentation about this behaviour. I changed to using
messages instead of pulses, but pulses are a more suitable mechanism.
Pulses do make a certain amount of sense for this behaviour, unfortunately
they do require the perms be right.
Hm… if you’re worried about the blockingness, and don’t want the clients
running as root, alternatives:
– have the resmgr have a thread/client, that essentially stays SEND/REPLY
blocked on the client. The client receives & stores away the rcvid,
and REPLYs regularly
– have the client have a thread that is in charge of making the sends
to the resmgr. Dispatch it internally in the client(s) using something
like a semaphore or a condition variable, and use the incrementing of
the semaphore/signalling of the condition variable as your heartbeat
call inside your client.
-David
–
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.