Fixed to run as root. tcgetsid() seems to have a bug when used on a /dev/ptmx fd as root.