def __pty_make_controlling_tty(self, tty_fd):
child_name = os.ttyname(tty_fd)<EOL>try:<EOL><INDENT>fd = os.open("<STR_LIT>", os.O_RDWR | os.O_NOCTTY);<EOL>if fd >= <NUM_LIT:0>:<EOL><INDENT>os.close(fd)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>os.setsid()<EOL>try:<EOL><INDENT>fd = os.open("<STR_LIT>", os.O_RDWR | os.O_NOCTTY);<EOL>if fd >= <NUM_LIT:0>:<EOL><INDENT>os.close(fd)<EOL>raise ExceptionPexpect("<STR_LIT>")<EOL><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>fd = os.open(child_name, os.O_RDWR);<EOL>if fd < <NUM_LIT:0>:<EOL><INDENT>raise ExceptionPexpect("<STR_LIT>" + child_name)<EOL><DEDENT>else:<EOL><INDENT>os.close(fd)<EOL><DEDENT>fd = os.open("<STR_LIT>", os.O_WRONLY)<EOL>if fd < <NUM_LIT:0>:<EOL><INDENT>raise ExceptionPexpect("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>os.close(fd)<EOL><DEDENT>
This makes the pseudo-terminal the controlling tty. This should be
        more portable than the pty.fork() function. Specifically, this should
        work on Solaris.