diff --git a/attach.c b/attach.c index 41a696c..5662b5d 100644 --- a/attach.c +++ b/attach.c @@ -40,8 +40,9 @@ restore_term(void) tcsetattr(0, TCSADRAIN, &orig_term); /* Make cursor visible. Assumes VT100. */ - printf("\033[?25h"); - fflush(stdout); + printf("\033[?1049l"); + printf("\033[0 q"); + fflush(stdout); } /* Connects to a unix domain socket */ @@ -88,9 +89,9 @@ die(int sig) { /* Print a nice pretty message for some things. */ if (sig == SIGHUP || sig == SIGINT) - printf(EOS "\r\n[detached]\r\n"); + printf("[detached]\r\n"); else - printf(EOS "\r\n[got signal %d - dying]\r\n", sig); + printf("[got signal %d - dying]\r\n", sig); exit(1); } @@ -115,7 +116,6 @@ process_kbd(int s, struct packet *pkt) /* And suspend... */ tcsetattr(0, TCSADRAIN, &orig_term); - printf(EOS "\r\n"); kill(getpid(), SIGTSTP); tcsetattr(0, TCSADRAIN, &cur_term); @@ -133,7 +133,7 @@ process_kbd(int s, struct packet *pkt) /* Detach char? */ else if (pkt->u.buf[0] == detach_char) { - printf(EOS "\r\n[detached]\r\n"); + printf("[detached]\r\n"); exit(0); } /* Just in case something pukes out. */ @@ -214,6 +214,8 @@ attach_main(int noerror) tcsetattr(0, TCSADRAIN, &cur_term); /* Clear the screen. This assumes VT100. */ + printf("\033[?1049h"); + fflush(stdout); write(1, "\33[H\33[J", 6); /* Tell the master that we want to attach. */ @@ -238,7 +240,7 @@ attach_main(int noerror) n = select(s + 1, &readfds, NULL, NULL, NULL); if (n < 0 && errno != EINTR && errno != EAGAIN) { - printf(EOS "\r\n[select failed]\r\n"); + printf("[select failed]\r\n"); exit(1); } @@ -249,13 +251,12 @@ attach_main(int noerror) if (len == 0) { - printf(EOS "\r\n[EOF - dtach terminating]" - "\r\n"); + printf("[EOF - dtach terminating]\r\n"); exit(0); } else if (len < 0) { - printf(EOS "\r\n[read returned an error]\r\n"); + printf("[read returned an error]\r\n"); exit(1); } /* Send the data to the terminal. */