From 06b3f49c49897558d5692b5f0480107b769be361 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Fri, 14 Aug 2009 21:28:00 +0000 Subject: [PATCH] Sync OpenBSD patchset 249: When started as the shell, __progname contains a leading -, so hardcode "tmux" for socket path and log files, and strip it when working out the shell. --- tmux.c | 7 +++---- window.c | 8 ++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tmux.c b/tmux.c index 902c240f..f707e8d1 100644 --- a/tmux.c +++ b/tmux.c @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.160 2009-08-14 21:04:04 tcunha Exp $ */ +/* $Id: tmux.c,v 1.161 2009-08-14 21:28:00 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -88,8 +88,7 @@ logfile(const char *name) log_close(); if (debug_level > 0) { - xasprintf( - &path, "%s-%s-%ld.log", __progname, name, (long) getpid()); + xasprintf(&path, "tmux-%s-%ld.log", name, (long) getpid()); log_open_file(debug_level, path); xfree(path); } @@ -193,7 +192,7 @@ makesockpath(const char *label) u_int uid; uid = getuid(); - xsnprintf(base, MAXPATHLEN, "%s/%s-%d", _PATH_TMP, __progname, uid); + xsnprintf(base, MAXPATHLEN, "%s/tmux-%d", _PATH_TMP, uid); if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) return (NULL); diff --git a/window.c b/window.c index 3d680149..5343479f 100644 --- a/window.c +++ b/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.101 2009-08-14 21:23:20 tcunha Exp $ */ +/* $Id: window.c,v 1.102 2009-08-14 21:28:00 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -60,6 +60,7 @@ const char * window_default_command(void) { const char *shell, *ptr; + char *progname; struct passwd *pw; shell = getenv("SHELL"); @@ -79,7 +80,10 @@ found: ptr++; else ptr = shell; - if (strcmp(ptr, __progname) == 0) + progname = __progname; + if (*progname == '-') + progname++; + if (strcmp(ptr, progname) == 0) return (_PATH_BSHELL); return (shell); }