Use TMPDIR if set, from Han Boetes.

This commit is contained in:
Nicholas Marriott
2011-01-12 22:23:58 +00:00
parent 47e18f4cea
commit b3438c86bf
2 changed files with 9 additions and 3 deletions

7
tmux.c
View File

@ -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);