From b3438c86bfb69bfdda55e15525abcacd33738686 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 12 Jan 2011 22:23:58 +0000 Subject: Use TMPDIR if set, from Han Boetes. --- tmux.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tmux.c') 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); -- cgit