c - Sending signal to certain (grand-...)grandchildren -


is there nice way send sigusr grandchild directly? e.g. have process tree:

     0     / \    1   2         \          3 

and need send signal 0 3.

i know save child's pid after forking , use kill() like

pid = fork(); if (pid == 0) {      pid = fork();     if (pid == 0) { /* grandchild */ }     savepid = pid; }  ...  kill(savepid,sig); 

but i'd have use shared memory make variable globally visible, not allowed in homework :)

there no direct communication between parent , grandchildren. usual approach here having grandchild store pid somewhere on filesystem (say, in /var/lib/myapp/grandchild.pid) , reading in parent.

you can use process groups on linux, offer coarse-grained approach.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -