def slave_open(tty_name):
 result = os.open(tty_name, os.O_RDWR)
 try:
  from fcntl import ioctl, I_PUSH
 except ImportError:
  return result
 try:
  ioctl(result, I_PUSH, 'ptem')
  ioctl(result, I_PUSH, 'ldterm')
 except IOError:
  pass
 return result

def slave_open ( tty_name ) : result = os . open ( tty_name , os . O_RDWR ) try : from fcntl import ioctl , I_PUSH except ImportError : return result try : ioctl ( result , I_PUSH , 'ptem' ) ioctl ( result , I_PUSH , 'ldterm' ) except IOError : pass return result
slave_open -> slave_fd open the pty slave and acquire the controlling terminal .