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:
< -1 Wait for any child process whose process group ID is equal to the absolute value of this value. -1 Wait for any child process. This is the same behavior as wait( ). 0 Wait for any child process that belongs to the same process group as the calling process. > 0 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.