21 static void pty_size(void);
23 static void c_write(char *buf
, int len
)
25 from_backend(0, buf
, len
);
29 * Called to set up the pty.
31 * Returns an error message, or NULL on success.
33 * Also places the canonical host name into `realhost'. It must be
34 * freed by the caller.
36 static char *pty_init(char *host
, int port
, char **realhost
, int nodelay
)
39 char name
[FILENAME_MAX
];
42 pty_master_fd
= open("/dev/ptmx", O_RDWR
);
44 if (pty_master_fd
< 0) {
45 perror("/dev/ptmx: open");
49 if (grantpt(pty_master_fd
) < 0) {
54 if (unlockpt(pty_master_fd
) < 0) {
59 name
[FILENAME_MAX
-1] = '\0';
60 strncpy(name
, ptsname(pty_master_fd
), FILENAME_MAX
-1);
62 slavefd
= open(name
, O_RDWR
);
64 perror("slave pty: open");
69 * Fork and execute the command.
86 fcntl(slavefd
, F_SETFD
, 0); /* don't close on exec */
92 tcsetpgrp(0, getpgrp());
93 /* Close everything _else_, for tidiness. */
94 for (i
= 3; i
< 1024; i
++)
96 execl(getenv("SHELL"), getenv("SHELL"), NULL
);
98 * If we're here, exec has gone badly foom.
110 * Called to send data down the pty.
112 static int pty_send(char *buf
, int len
)
115 int ret
= write(pty_master_fd
, buf
, len
);
117 perror("write pty master");
127 * Called to query the current socket sendability status.
129 static int pty_sendbuffer(void)
135 * Called to set the size of the window
137 static void pty_size(void)
139 /* FIXME: will need to do TIOCSWINSZ or whatever. */
144 * Send special codes.
146 static void pty_special(Telnet_Special code
)
152 static Socket
pty_socket(void)
154 return NULL
; /* shouldn't ever be needed */
157 static int pty_sendok(void)
162 static void pty_unthrottle(int backlog
)
167 static int pty_ldisc(int option
)
169 return 0; /* neither editing nor echoing */
172 static int pty_exitcode(void)
174 /* Shouldn't ever be required */
178 Backend pty_backend
= {