ttyfd
int ttyfd;
if ((ttyfd = open(DEVTTY, O_RDWR)) >= 0) {
if ((ttyoutf = fdopen(ttyfd, "w")) != NULL) {
if ((ttyinf = fdopen(ttyfd, "r")) != NULL)
(void)close(ttyfd);
if (ttyfd >= 0 && tcsetpgrp(ttyfd, rootpid) < 0)
static int ttyfd = -1;
if (ttyfd >= 0) {
close(ttyfd);
ttyfd = -1;
if (ttyfd != -1)
close(ttyfd);
if ((ttyfd = open(_PATH_TTY, O_RDWR | O_CLOEXEC)) < 0) {
(ttyfd = fcntl(i, F_DUPFD_CLOEXEC, 10)) < 0) {
if (ttyfd < 10) {
if ((i = fcntl(ttyfd, F_DUPFD_CLOEXEC, 10)) < 0) {
close(ttyfd);
ttyfd = i;
initialpgrp = tcgetpgrp(ttyfd);
tcsetpgrp(ttyfd, rootpid);
if (ttyfd >= 0) {
tcsetpgrp(ttyfd, initialpgrp);
close(ttyfd);
ttyfd = -1;
if (ttyfd >= 0)
tcsetpgrp(ttyfd, pgrp);
ttyfd >= 0) {
if (tcsetpgrp(ttyfd, pgrp) < 0)
static int ttyfd = -1;
tcgetattr(ttyfd, &termbuf);
tcsetattr(ttyfd, TCSANOW, &termbuf);
ttyfd = t;
if (s->ttyfd != -1) {
res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));
if (dup2(s->ttyfd, 0) == -1)
mm_send_fd(sock, s->ttyfd) == -1)
close(s->ttyfd);
s->ttyfd = s->ptyfd;
debug3_f("tty %s ptyfd %d", s->tty, s->ttyfd);
mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
(*ttyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1)
if (s->ttyfd == -1)
s->ttyfd = -1;
int rppflags, ttyfd, use_askpass = 0, allow_askpass = 0;
ttyfd = open(_PATH_TTY, O_RDWR);
if (ttyfd >= 0) {
(void)write(ttyfd, &cr, 1);
close(ttyfd);
if (s->ttyfd != -1)
if (s->ttyfd != -1) {
session_setup_sia(pw, s->ttyfd == -1 ? NULL : s->tty);
sessions[id].ttyfd = -1;
if (s->used && s->ttyfd != -1 && strcmp(s->tty, tty) == 0) {
if (s->ttyfd != -1) {
if (!mm_pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty))) {
s->ttyfd = -1;
ssh_tty_parse_modes(ssh, s->ttyfd);
if (s->ttyfd == -1)
s->ttyfd = -1;
if (s->ttyfd != -1)
if (s->ttyfd != -1)
debug_f("channel %d: has child, ttyfd %d", id, s->ttyfd);
if (s->ttyfd != -1)
if (s->used && s->ttyfd != -1) {
int fdout, ptyfd, ttyfd, ptymaster;
ttyfd = s->ttyfd;
close(ttyfd);
close(ttyfd);
close(ttyfd);
pty_make_controlling_tty(&ttyfd, s->tty);
if (dup2(ttyfd, 0) == -1)
if (dup2(ttyfd, 1) == -1)
if (dup2(ttyfd, 2) == -1)
close(ttyfd);
close(ttyfd);
if (s->ttyfd != -1) {
else if (s->ttyfd == -1) {
if (s->ttyfd != -1)
int ptyfd, ttyfd, ptymaster;
pty_make_controlling_tty(int *ttyfd, const char *tty)
if (ioctl(*ttyfd, TIOCSCTTY, NULL) < 0)
pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
i = openpty(ptyfd, ttyfd, NULL, NULL, NULL);
name = ttyname(*ttyfd);
int ttyfd;
ttyfd = open(devnam, O_RDONLY);
if (ttyfd == -1)
if (ioctl(ttyfd, TIOCCONS, &flag) == -1)
close(ttyfd);
static int ttyfd = -1;
if (ttyfd < 0)
ttyfd = open(_PATH_TTY, O_RDONLY);
if (ttyfd >= 0) {
if ((nr = read(ttyfd, buf, buf_size)) > 0 &&
if (ttyfd < 0 || nr <= 0) {
ttyread(struct ttyfd *tf, uint8_t *ret)
ttywrite(struct ttyfd *tf, unsigned char wb)
struct ttyfd tty;
ttyopen(struct ttyfd *tf)