os.setpgid()

os.setpgid(pid, pgrp)

Call the system call setpgid().