Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two small patches #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ restore_term(void)
tcsetattr(0, TCSADRAIN, &orig_term);

/* Make cursor visible. Assumes VT100. */
printf("\033[?25h");
if (!no_ansiterm)
printf("\033[?25h");
fflush(stdout);
if (no_ansiterm)
(void)system("tput init 2>/dev/null");
}

/* Connects to a unix domain socket */
Expand Down Expand Up @@ -214,7 +217,8 @@ attach_main(int noerror)
tcsetattr(0, TCSADRAIN, &cur_term);

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

/* Tell the master that we want to attach. */
memset(&pkt, 0, sizeof(struct packet));
Expand Down
2 changes: 1 addition & 1 deletion dtach.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#endif

extern char *progname, *sockname;
extern int detach_char, no_suspend, redraw_method;
extern int detach_char, no_suspend, redraw_method, no_ansiterm;
extern struct termios orig_term;
extern int dont_have_tty;

Expand Down
5 changes: 5 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ int detach_char = '\\' - 64;
int no_suspend;
/* The default redraw method. Initially set to unspecified. */
int redraw_method = REDRAW_UNSPEC;
/* 1 if we should not send ansi sequences to the terminal */
int no_ansiterm = 0;

/*
** The original terminal settings. Shared between the master and attach
Expand Down Expand Up @@ -78,6 +80,7 @@ usage()
"\t\t ctrl_l: Send a Ctrl L character to the program.\n"
"\t\t winch: Send a WINCH signal to the program.\n"
" -z\t\tDisable processing of the suspend key.\n"
" -t\t\tDisable VT100 assumptions.\n"
"\nReport any bugs to <" PACKAGE_BUGREPORT ">.\n",
PACKAGE_VERSION, __DATE__, __TIME__);
exit(0);
Expand Down Expand Up @@ -158,6 +161,8 @@ main(int argc, char **argv)
detach_char = -1;
else if (*p == 'z')
no_suspend = 1;
else if (*p == 't')
no_ansiterm = 1;
else if (*p == 'e')
{
++argv; --argc;
Expand Down
3 changes: 3 additions & 0 deletions master.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,17 @@ create_socket(char *name)
{
int s;
struct sockaddr_un sockun;
mode_t omask;

if (strlen(name) > sizeof(sockun.sun_path) - 1)
{
errno = ENAMETOOLONG;
return -1;
}

omask = umask(077);
s = socket(PF_UNIX, SOCK_STREAM, 0);
umask(omask); /* umask always succeeds, errno is untouched. */
if (s < 0)
return -1;
sockun.sun_family = AF_UNIX;
Expand Down