summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-01-12 22:23:58 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-01-12 22:23:58 +0000
commitb3438c86bfb69bfdda55e15525abcacd33738686 (patch)
tree761213d7f4cb2b2fea4f7f6d465dccab42fd1b9e
parent47e18f4ceacc4c207dc0d392f51d55b2286672f2 (diff)
Use TMPDIR if set, from Han Boetes.
-rw-r--r--tmux.15
-rw-r--r--tmux.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/tmux.1 b/tmux.1
index 27a0c997..cf244782 100644
--- a/tmux.1
+++ b/tmux.1
@@ -134,7 +134,10 @@ will report an error and exit without executing further commands.
.It Fl L Ar socket-name
.Nm
stores the server socket in a directory under
-.Pa /tmp ;
+.Pa /tmp
+(or
+.Ev TMPDIR
+if set);
the default socket is named
.Em default .
This option allows a different socket name to be specified, allowing several
diff --git a/tmux.c b/tmux.c
index 3b40da12..0225f5f6 100644
--- a/tmux.c
+++ b/tmux.c
@@ -169,12 +169,15 @@ parseenvironment(void)
char *
makesocketpath(const char *label)
{
- char base[MAXPATHLEN], *path;
+ char base[MAXPATHLEN], *path, *s;
struct stat sb;
u_int uid;
uid = getuid();
- xsnprintf(base, MAXPATHLEN, "%s/tmux-%d", _PATH_TMP, uid);
+ if ((s = getenv("TMPDIR")) == NULL || *s == '\0')
+ xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid);
+ else
+ xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid);
if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST)
return (NULL);