pty.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*++
  2. Copyright (c) 2015 Minoca Corp.
  3. This file is licensed under the terms of the GNU Lesser General Public
  4. License version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details.
  6. Module Name:
  7. pty.h
  8. Abstract:
  9. This header contains definitions for manipulating pseudo-terminals in the
  10. C Library.
  11. Author:
  12. Evan Green 2-Feb-2015
  13. --*/
  14. #ifndef _PTY_H
  15. #define _PTY_H
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include <sys/ioctl.h>
  20. #include <sys/types.h>
  21. #include <termios.h>
  22. //
  23. // ---------------------------------------------------------------- Definitions
  24. //
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. //
  29. // ------------------------------------------------------ Data Type Definitions
  30. //
  31. //
  32. // -------------------------------------------------------------------- Globals
  33. //
  34. //
  35. // -------------------------------------------------------- Function Prototypes
  36. //
  37. LIBC_API
  38. int
  39. openpty (
  40. int *Master,
  41. int *Slave,
  42. char *Name,
  43. const struct termios *Settings,
  44. const struct winsize *WindowSize
  45. );
  46. /*++
  47. Routine Description:
  48. This routine creates a new pseudo-terminal device.
  49. Arguments:
  50. Master - Supplies a pointer where a file descriptor to the master will be
  51. returned on success.
  52. Slave - Supplies a pointer where a file descriptor to the slave will be
  53. returned on success.
  54. Name - Supplies an optional pointer where the name of the slave terminal
  55. will be returned on success. This buffer must be PATH_MAX size in bytes
  56. if supplied.
  57. Settings - Supplies an optional pointer to the settings to apply to the
  58. new terminal.
  59. WindowSize - Supplies an optional pointer to the window size to set in the
  60. new terminal.
  61. Return Value:
  62. 0 on success.
  63. -1 on failure, and errno will be set to contain more information.
  64. --*/
  65. LIBC_API
  66. pid_t
  67. forkpty (
  68. int *Master,
  69. char *Name,
  70. const struct termios *Settings,
  71. const struct winsize *WindowSize
  72. );
  73. /*++
  74. Routine Description:
  75. This routine combines openpty, fork, and login_tty to create a new process
  76. wired up to a pseudo-terminal.
  77. Arguments:
  78. Master - Supplies a pointer where a file descriptor to the master will be
  79. returned on success. This is only returned in the parent.
  80. Name - Supplies an optional pointer where the name of the slave terminal
  81. will be returned on success. This buffer must be PATH_MAX size in bytes
  82. if supplied.
  83. Settings - Supplies an optional pointer to the settings to apply to the
  84. new terminal.
  85. WindowSize - Supplies an optional pointer to the window size to set in the
  86. new terminal.
  87. Return Value:
  88. Returns the pid of the forked child on success in the parent.
  89. 0 on success in the child.
  90. -1 on failure, and errno will be set to contain more information.
  91. --*/
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif