Add TMUX_TMPDIR variable to put the socket directory outside

TMPDIR. From Ben Boeckel.
This commit is contained in:
Nicholas Marriott 2013-03-27 11:24:18 +00:00
parent 5e4d9a3197
commit 7f63658709
2 changed files with 11 additions and 17 deletions

13
tmux.1
View File

@ -98,10 +98,6 @@ The options are as follows:
Force Force
.Nm .Nm
to assume the terminal supports 256 colours. to assume the terminal supports 256 colours.
.It Fl 8
Like
.Fl 2 ,
but indicates that the terminal supports 88 colours.
.It Fl C .It Fl C
Start in control mode. Start in control mode.
Given twice Given twice
@ -145,11 +141,12 @@ session created, and continues to process the rest of the configuration file.
.It Fl L Ar socket-name .It Fl L Ar socket-name
.Nm .Nm
stores the server socket in a directory under stores the server socket in a directory under
.Pa /tmp .Ev TMUX_TMPDIR ,
(or
.Ev TMPDIR .Ev TMPDIR
if set); if it is unset, or
the default socket is named .Pa /tmp
if both are unset.
The default socket is named
.Em default . .Em default .
This option allows a different socket name to be specified, allowing several This option allows a different socket name to be specified, allowing several
independent independent

15
tmux.c
View File

@ -164,10 +164,12 @@ makesocketpath(const char *label)
u_int uid; u_int uid;
uid = getuid(); uid = getuid();
if ((s = getenv("TMPDIR")) == NULL || *s == '\0') if ((s = getenv("TMUX_TMPDIR")) != NULL && *s != '\0')
xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid); xsnprintf(base, sizeof base, "%s/", s);
else else if ((s = getenv("TMPDIR")) != NULL && *s != '\0')
xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid); xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid);
else
xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid);
if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST)
return (NULL); return (NULL);
@ -244,15 +246,10 @@ main(int argc, char **argv)
quiet = flags = 0; quiet = flags = 0;
label = path = NULL; label = path = NULL;
login_shell = (**argv == '-'); login_shell = (**argv == '-');
while ((opt = getopt(argc, argv, "28c:Cdf:lL:qS:uUv")) != -1) { while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUv")) != -1) {
switch (opt) { switch (opt) {
case '2': case '2':
flags |= IDENTIFY_256COLOURS; flags |= IDENTIFY_256COLOURS;
flags &= ~IDENTIFY_88COLOURS;
break;
case '8':
flags |= IDENTIFY_88COLOURS;
flags &= ~IDENTIFY_256COLOURS;
break; break;
case 'c': case 'c':
free(shell_cmd); free(shell_cmd);