getsid
extern pid_t getsid(pid_t pid);
pid_t sessionID = getsid(processID);
result = getsid(process);
if (pid != getsid(0)) {