inn.qnx.com <anup@tamu.edu> wrote:
Hi,
Suppose I have a main process - MAIN . This process spawns a new process
using the command
spawnl(P_NOWAIT,“A”,“A”,0)
Now I attach a proxy to “A” by doing a qnx_proxy_attach(…) in MAIN.
This is generally not a good idea – the person who is going to
receive the proxy should be the process attaching the proxy.
And I am going to trigger this proxy from MAIN.
But in “A” I need to know for some reason what the PID of the proxy
attached to “A” was.
This is part of the reason it is bad for someone to attach a proxy to
someone else. (Another part of the reason, is that doing it this way
can’t work in the networked case, that is, if “A” was spawned on a
different node of the network.)
“A” should attach the proxy, then send MAIN a message with the proxy-id
for MAIN to trigger. (This can work in the networked case, though it
requires a bit of extra work, including a qnx_proxy_rem_attach().)
How can I know the proxy of the PID attached to “A” by MAIN in “A”?
MAIN would have to tell “A” what it is. There is no “magic” way to
know it.
I have noticed that generally if i do a spawnl(…), followed by a
proxy_attach, then the pid of the proxy is PID_of_spawned_process +1.
But this is not always the case when the program runs for a long time…
In fact, this is NOT dependable at all, it just happens that is likely
to be the next free entry in the process table – but this involves race
conditions and stuff.
-David
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.