Skip to content

Commit

Permalink
Improve passthrough mode a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjl committed Jan 16, 2012
1 parent 374e14f commit d6c9bd5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions attach.c
Expand Up @@ -140,7 +140,7 @@ process_kbd(int s, struct packet *pkt)
}

int
attach_main(int noerror, int noclear)
attach_main(int noerror, int passthrough)
{
struct packet pkt;
unsigned char buf[BUFSIZE];
Expand All @@ -163,7 +163,8 @@ attach_main(int noerror, int noclear)
cur_term = orig_term;

/* Set a trap to restore the terminal when we die. */
atexit(restore_term);
if (!passthrough)
atexit(restore_term);

/* Set some signals. */
signal(SIGPIPE, SIG_IGN);
Expand All @@ -187,7 +188,7 @@ attach_main(int noerror, int noclear)
tcsetattr(0, TCSADRAIN, &cur_term);

/* Clear the screen. This assumes VT100. */
if (!noclear)
if (!passthrough)
write(1, "\33[H\33[J", 6);

/* Tell the master that we want to attach. */
Expand Down Expand Up @@ -232,7 +233,8 @@ attach_main(int noerror, int noclear)
exit(1);
}
/* Send the data to the terminal. */
write(1, buf, len);
if (!passthrough)
write(1, buf, len);
n--;
}
/* stdin activity */
Expand All @@ -243,7 +245,7 @@ attach_main(int noerror, int noclear)
pkt.len = read(0, pkt.u.buf, sizeof(pkt.u.buf));

if (pkt.len <= 0)
exit(1);
exit(0);
process_kbd(s, &pkt);
n--;
}
Expand Down

0 comments on commit d6c9bd5

Please sign in to comment.