Setgid on the same thread that tries to open the pipes--otherwise the open might fail if the GID doesn't match the requested gid