About wait

Hi everyone

I'm novice at Unix programming and I hope to post this thread in the correct place.
I have the following doubts:
1 Suppose we have some processes which are B's children process and another process A which has no relation with B and its children.
Can A do wait () for a children of B even if A is not the parent in any way?

wait() simply returns the status of one of the terminated children. You can't specify which child to wait() for. The kernel won't accidently return the status of a terminated process belonging to some other parent. There is a waitpid() but it is an error to specify a non-child pid or a pid that does not exist at all.

So in a nutshell only the parent can wait for the children.
Is there a reason for this ?
Imagine you have a process which want to monitor the other process, the unique way is to be the parent of all them, just like init.

waiting consumes the zombie. If some other process did that the parent could not learn the exit status of its own children. For security, one user's process cannot affect another user's process. But if you own the process or you are root, you can check it. Try to use the kill system call to send signal zero to the process in question. Signal zero has no effect on the process. But the process must exist or the kill() system call will fail.

Sure. The reasoning of it is the entire design architecture
behind a session and process group. If you are not familiar with
these unix concepts programatically W.Richard Stevens
is an invaluable resource.
It sounds like you may be coming from a windows environment.

As Perderabo notes the ability for a process to wait
on another processes session or process group introduces
ineradicable security issues for unix and unix-alikes.
A threaded model is more easily adapted because of
shared address space.

My advice is to use threads if you are uncomfortable with the process paradigm.

Thank you too, ramen_noodle.
I have to learn how to manage the processes too, not only threads.
Bye