I searched a lot but didn't find a solution. So it can be silly question.
The format of waitpid is
pid_t waitpid (pid_t pid, int *status, int options)
The pid parameter specifies exactly which process or processes to wait for. Its values fall into four camps:
Wait for any child process whose process group ID is equal to the absolute value of this value.
Wait for any child process. This is the same behavior as wait( ).
Wait for any child process that belongs to the same process group as the calling process.
Wait for any child process whose pid is exactly the value provided.
Now the question is what if parent and child have different group id and group id of child is 1. How to use waitpid for this specific child? Because we can't use -1 it will tell to wait for any child.