tcgetsid common code