Return the process group id of the process with process id pid. If pid is 0, the process group id of the current process is returned.
os.getpgid(pid)