/Doc/library/pty.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 48 lines · 31 code · 17 blank · 0 comment · 0 complexity · 3d17a9ba3039fd35befd9c73b36ef3ca MD5 · raw file

  1. :mod:`pty` --- Pseudo-terminal utilities
  2. ========================================
  3. .. module:: pty
  4. :platform: IRIX, Linux
  5. :synopsis: Pseudo-Terminal Handling for SGI and Linux.
  6. .. moduleauthor:: Steen Lumholt
  7. .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
  8. The :mod:`pty` module defines operations for handling the pseudo-terminal
  9. concept: starting another process and being able to write to and read from its
  10. controlling terminal programmatically.
  11. Because pseudo-terminal handling is highly platform dependent, there is code to
  12. do it only for SGI and Linux. (The Linux code is supposed to work on other
  13. platforms, but hasn't been tested yet.)
  14. The :mod:`pty` module defines the following functions:
  15. .. function:: fork()
  16. Fork. Connect the child's controlling terminal to a pseudo-terminal. Return
  17. value is ``(pid, fd)``. Note that the child gets *pid* 0, and the *fd* is
  18. *invalid*. The parent's return value is the *pid* of the child, and *fd* is a
  19. file descriptor connected to the child's controlling terminal (and also to the
  20. child's standard input and output).
  21. .. function:: openpty()
  22. Open a new pseudo-terminal pair, using :func:`os.openpty` if possible, or
  23. emulation code for SGI and generic Unix systems. Return a pair of file
  24. descriptors ``(master, slave)``, for the master and the slave end, respectively.
  25. .. function:: spawn(argv[, master_read[, stdin_read]])
  26. Spawn a process, and connect its controlling terminal with the current
  27. process's standard io. This is often used to baffle programs which insist on
  28. reading from the controlling terminal.
  29. The functions *master_read* and *stdin_read* should be functions which read from
  30. a file descriptor. The defaults try to read 1024 bytes each time they are
  31. called.