Try to change the window title to match the command running it in. This is done

by reading argv[0] from the process group leader of the group that owns the tty
(tcgetpgrp()). This can't be done portably so some OS-dependent code is
introduced (ugh); OpenBSD, FreeBSD and Linux are supported at the moment.

A new window flag, automatic-rename, is available: if this is set to off, the
window name is not changed. Specifying a name with the new-window, new-session
or rename-window commands will automatically set this flag to off for the
window in question. To disable it entirely set the option to off globally (setw
-g automatic-rename off).
pull/1/head
Nicholas Marriott 2009-01-20 19:35:03 +00:00
parent d4f034beb4
commit 2d15f59859
16 changed files with 399 additions and 50 deletions

15
CHANGES
View File

@ -1,3 +1,16 @@
20 January 2009
* Try to change the window title to match the command running it in. This is
done by reading argv[0] from the process group leader of the group that owns
the tty (tcgetpgrp()). This can't be done portably so some OS-dependent code
is introduced (ugh); OpenBSD, FreeBSD and Linux are supported at the moment.
A new window flag, automatic-rename, is available: if this is set to off, the
window name is not changed. Specifying a name with the new-window,
new-session or rename-window commands will automatically set this flag to off
for the window in question. To disable it entirely set the option to off
globally (setw -g automatic-rename off).
19 January 2009
* Fix various stupid issues when the status line is turned off. Grr.
@ -970,7 +983,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.224 2009-01-19 20:14:55 nicm Exp $
$Id: CHANGES,v 1.225 2009-01-20 19:35:03 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms

View File

@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.62 2009-01-18 17:20:52 nicm Exp $
# $Id: GNUmakefile,v 1.63 2009-01-20 19:35:03 nicm Exp $
.PHONY: clean
@ -40,7 +40,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
window-clock.c window-scroll.c window-more.c window-copy.c \
window-choose.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
tty.c tty-term.c tty-keys.c tty-write.c util.c
tty.c tty-term.c tty-keys.c tty-write.c util.c names.c \
osdep-unknown.c osdep-openbsd.c osdep-freebsd.c osdep-linux.c
CC?= gcc
INCDIRS+= -I. -I-

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.102 2009-01-18 17:20:52 nicm Exp $
# $Id: Makefile,v 1.103 2009-01-20 19:35:03 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html
@ -44,7 +44,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
window-clock.c window-scroll.c window-more.c window-copy.c \
window-choose.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
tty.c tty-term.c tty-keys.c tty-write.c util.c
tty.c tty-term.c tty-keys.c tty-write.c util.c names.c \
osdep-unknown.c osdep-openbsd.c osdep-freebsd.c osdep-linux.c
CC?= cc
INCDIRS+= -I. -I- -I/usr/local/include
@ -82,7 +83,7 @@ LIBS+= -lutil -lncurses
.if ${OS} == "FreeBSD" || ${OS} == "DragonFly"
INCDIRS+= -Icompat
SRCS+= compat/vis.c
CFLAGS+= -DUSE_LIBUTIL_H
CFLAGS+= -DUSE_LIBUTIL_H -DNO_QUEUE_H -DNO_TREE_H
LIBS+= -lcrypt
.endif

24
TODO
View File

@ -58,32 +58,32 @@
keyboard. what about a new-window-index option that sets the base at which
tmux starts numbering new windows, then they can do: set -g new-window-index
1; bind 0 selectw -t:10
(hopefully) for 0.7, in no particular order:
- swap-pane-up, swap-pane-down (maybe move-pane-*)
- move-pane (to window) (maybe break-pane?)
- some way to change status line colours based on something? command?
- client sx/sy should be in tty, then can let the terminal wrap at edge
to allow xterm to pick up it should be one line for its c/p
- should be able to move to a hidden pane and it would be moved into view. pane
number in status line/top-right would be cool for this
- command to run something without a window at all - output to
window-more. what for? isnt this the same as doing it w/ splitw/neww now?
- command to purge window history? or apply history-limit changes?
- clone session command
- make command sequences more usable: don't require space around ;, handle
errors better
(hopefully) for 0.7, in no particular order:
- swap-pane-up, swap-pane-down (maybe move-pane-*)
- move-pane (to window) (maybe break-pane?)
- command: load-buffer -b number filename
- command: copy-buffer -s src-session -t dst-session -a src-index -b dst-index
(copy from other session)
- neww should support -k
- flag to scroll-mode/copy-mode to automatically scroll up a page
- would be nice if tmux could be the shell
- would be nice if tmux could be the shell (tmux attach, but hard link to tmux
binary as "tmuxsh" or wrapper script?)
- key to switch to copy mode from scroll mode
- clone session command
- document suspend-client
- document command sequences
- make command sequences more usable: don't require space around ;, handle
errors better
- document find-window
- bring back -l/-p on splitw so i can do "splitw -p 75 elinks"
- UTF-8 combining characters don't work (probably should be width 1 but are
listed as 2)
- client sx/sy should be in tty, then can let the terminal wrap at edge
to allow xterm to pick up it should be one line for its c/p
- with no status line and when window sy<cy, use blank line
- doesn't redraw last line properly when status is off

View File

@ -1,4 +1,4 @@
/* $Id: cmd-new-session.c,v 1.36 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: cmd-new-session.c,v 1.37 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -169,6 +169,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (data->winname != NULL) {
xfree(s->curw->window->name);
s->curw->window->name = xstrdup(data->winname);
options_set_number(
&s->curw->window->options, "automatic-rename", 0);
}
if (data->flag_detached) {

View File

@ -1,4 +1,4 @@
/* $Id: cmd-rename-window.c,v 1.25 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: cmd-rename-window.c,v 1.26 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -53,6 +53,7 @@ cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
xfree(wl->window->name);
wl->window->name = xstrdup(data->arg);
options_set_number(&wl->window->options, "automatic-rename", 0);
server_status_session(s);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-window-option.c,v 1.21 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: cmd-set-window-option.c,v 1.22 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -55,6 +55,7 @@ const char *set_option_clock_mode_style_list[] = {
};
const struct set_option_entry set_window_option_table[NSETWINDOWOPTION] = {
{ "aggressive-resize", SET_OPTION_FLAG, 0, 0, NULL },
{ "automatic-rename", SET_OPTION_FLAG, 0, 0, NULL },
{ "clock-mode-colour", SET_OPTION_COLOUR, 0, 0, NULL },
{ "clock-mode-style",
SET_OPTION_CHOICE, 0, 0, set_option_clock_mode_style_list },

110
names.c Normal file
View File

@ -0,0 +1,110 @@
/* $Id: names.c,v 1.1 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include "tmux.h"
char *parse_window_name(const char *);
void
set_window_names(void)
{
struct window *w;
u_int i;
pid_t pgrp;
char *name;
struct timeval tv, tv2;
if (gettimeofday(&tv, NULL) != 0)
fatal("gettimeofday");
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
w = ARRAY_ITEM(&windows, i);
if (w == NULL || w->active == NULL)
continue;
if (!options_get_number(&w->options, "automatic-rename"))
continue;
if (timercmp(&tv, &w->name_timer, <))
continue;
memcpy(&w->name_timer, &tv, sizeof w->name_timer);
tv2.tv_sec = 0;
tv2.tv_usec = NAME_INTERVAL * 1000L;
timeradd(&w->name_timer, &tv2, &w->name_timer);
if (w->active->screen != &w->active->base)
pgrp = -1;
else if ((pgrp = tcgetpgrp(w->active->fd)) == w->pgrp)
continue;
w->pgrp = pgrp;
name = get_argv0(pgrp);
if (pgrp == -1 || name == NULL)
name = default_window_name(w);
else
name = parse_window_name(name);
if (strcmp(name, w->name) == 0)
xfree(name);
else {
xfree(w->name);
w->name = name;
server_status_window(w);
}
}
}
char *
default_window_name(struct window *w)
{
if (w->active->screen != &w->active->base)
return (xstrdup("[tmux]"));
return (parse_window_name(w->active->cmd));
}
char *
parse_window_name(const char *in)
{
char *copy, *name, *ptr;
name = copy = xstrdup(in);
if (strncmp(name, "exec ", (sizeof "exec ") - 1) == 0)
name = name + (sizeof "exec ") - 1;
while (*name == ' ')
name++;
if ((ptr = strchr(name, ' ')) != NULL)
*ptr = '\0';
if (*name != '\0') {
ptr = name + strlen(name) - 1;
while (ptr > name && !isalnum(*ptr))
*ptr-- = '\0';
}
if (*name == '/')
name = xbasename(name);
name = xstrdup(name);
xfree(copy);
return (name);
}

64
osdep-freebsd.c Normal file
View File

@ -0,0 +1,64 @@
/* $Id: osdep-freebsd.c,v 1.1 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef __FreeBSD__
#include <sys/param.h>
#include <sys/sysctl.h>
#include <err.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
char *get_argv0(pid_t);
char *
get_argv0(pid_t pgrp)
{
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, 0 };
size_t size;
char *args, *args2, *procname;
procname = NULL;
mib[3] = pgrp;
args = NULL;
size = 128;
while (size < SIZE_MAX / 2) {
size *= 2;
if ((args2 = realloc(args, 2 * size)) == NULL)
break;
args = args2;
if (sysctl(mib, 4, args, &size, NULL, 0) == -1) {
if (errno == ENOMEM)
continue;
break;
}
procname = strdup(args);
break;
}
free(args);
return (procname);
}
#endif

55
osdep-linux.c Normal file
View File

@ -0,0 +1,55 @@
/* $Id: osdep-linux.c,v 1.1 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef __linux__
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include "tmux.h"
char *
get_argv0(pid_t pgrp)
{
FILE *f;
char *path, *buf;
size_t len;
int ch;
xasprintf(&path, "/proc/%lld/cmdline", (long long) pgrp);
if ((f = fopen(path, "r")) == NULL)
return (NULL);
len = 0;
buf = NULL;
while ((ch = fgetc(f)) != EOF) {
if (ch == '\0')
break;
buf = xrealloc(buf, 1, len + 2);
buf[len++] = ch;
}
if (buf != NULL)
buf[len] = '\0';
return (buf);
}
#endif

63
osdep-openbsd.c Normal file
View File

@ -0,0 +1,63 @@
/* $Id: osdep-openbsd.c,v 1.1 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef __OpenBSD__
#include <sys/param.h>
#include <sys/sysctl.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
char *get_argv0(pid_t);
char *
get_argv0(pid_t pgrp)
{
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, 0, KERN_PROC_ARGV };
size_t size;
char **args, **args2, *procname;
procname = NULL;
mib[2] = pgrp;
args = NULL;
size = 128;
while (size < SIZE_MAX / 2) {
size *= 2;
if ((args2 = realloc(args, 2 * size)) == NULL)
break;
args = args2;
if (sysctl(mib, 4, args, &size, NULL, 0) == -1) {
if (errno == ENOMEM)
continue;
break;
}
procname = strdup(*args);
break;
}
free(args);
return (procname);
}
#endif

31
osdep-unknown.c Normal file
View File

@ -0,0 +1,31 @@
/* $Id: osdep-unknown.c,v 1.1 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__linux__)
#include <sys/types.h>
#include "tmux.h"
char *
get_argv0(unused pid_t pgrp)
{
return (NULL);
}
#endif

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.109 2009-01-19 17:16:09 nicm Exp $ */
/* $Id: server.c,v 1.110 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -276,6 +276,9 @@ server_main(const char *srv_path, int srv_fd)
server_second_timers();
}
/* Set window names. */
set_window_names();
/*
* Handle window and client sockets. Clients can create
* windows, so windows must come first to avoid messing up by

3
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.99 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: tmux.c,v 1.100 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -256,6 +256,7 @@ main(int argc, char **argv)
options_set_number(&global_window_options, "clock-mode-style", 1);
options_set_number(&global_window_options, "force-height", 0);
options_set_number(&global_window_options, "force-width", 0);
options_set_number(&global_window_options, "automatic-rename", 1);
options_set_number(&global_window_options, "mode-bg", 3);
options_set_number(&global_window_options, "mode-fg", 0);
options_set_number(&global_window_options, "mode-keys", MODEKEY_EMACS);

16
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.244 2009-01-19 18:26:50 nicm Exp $ */
/* $Id: tmux.h,v 1.245 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -123,6 +123,9 @@ extern const char *__progname;
/* Minimum pane size. */
#define PANE_MINIMUM 4 /* includes separator line */
/* Automatic name refresh interval, in milliseconds. */
#define NAME_INTERVAL 100
/* Fatal errors. */
#define fatal(msg) log_fatal("%s: %s", __func__, msg);
#define fatalx(msg) log_fatalx("%s: %s", __func__, msg);
@ -606,6 +609,8 @@ TAILQ_HEAD(window_panes, window_pane);
/* Window structure. */
struct window {
char *name;
struct timeval name_timer;
pid_t pgrp;
struct window_pane *active;
struct window_panes panes;
@ -903,7 +908,7 @@ struct set_option_entry {
extern const struct set_option_entry set_option_table[];
extern const struct set_option_entry set_window_option_table[];
#define NSETOPTION 20
#define NSETWINDOWOPTION 12
#define NSETWINDOWOPTION 13
/* Edit keys. */
enum mode_key {
@ -1460,6 +1465,10 @@ void printflike3 window_choose_add(
void window_choose_ready(struct window_pane *,
u_int, void (*)(void *, int), void *);
/* names.c */
void set_window_names(void);
char *default_window_name(struct window *);
/* session.c */
extern struct sessions sessions;
void session_alert_add(struct session *, struct window *, int);
@ -1489,6 +1498,9 @@ int utf8_width(u_int);
/* util.c */
char *section_string(char *, size_t, size_t, size_t);
/* osdep-*.c */
char *get_argv0(pid_t);
/* buffer.c */
struct buffer *buffer_create(size_t);
void buffer_destroy(struct buffer *);

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.59 2009-01-18 18:31:45 nicm Exp $ */
/* $Id: window.c,v 1.60 2009-01-20 19:35:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -205,42 +205,19 @@ window_create(const char *name, const char *cmd,
{
struct window *w;
u_int i;
char *ptr, *copy;
w = xmalloc(sizeof *w);
w->flags = 0;
TAILQ_INIT(&w->panes);
w->active = NULL;
w->pgrp = -1;
w->sx = sx;
w->sy = sy;
options_init(&w->options, &global_window_options);
if (name == NULL) {
/* XXX */
if (strncmp(cmd, "exec ", (sizeof "exec ") - 1) == 0)
copy = xstrdup(cmd + (sizeof "exec ") - 1);
else
copy = xstrdup(cmd);
if ((ptr = strchr(copy, ' ')) != NULL) {
if (ptr != copy && ptr[-1] != '\\')
*ptr = '\0';
else {
while ((ptr = strchr(ptr + 1, ' ')) != NULL) {
if (ptr[-1] != '\\') {
*ptr = '\0';
break;
}
}
}
}
w->name = xstrdup(xbasename(copy));
xfree(copy);
} else
w->name = xstrdup(name);
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
if (ARRAY_ITEM(&windows, i) == NULL) {
ARRAY_SET(&windows, i, w);
@ -256,6 +233,12 @@ window_create(const char *name, const char *cmd,
return (NULL);
}
w->active = TAILQ_FIRST(&w->panes);
if (name != NULL) {
w->name = xstrdup(name);
options_set_number(&w->options, "automatic-rename", 0);
} else
w->name = default_window_name(w);
return (w);
}
@ -548,6 +531,7 @@ window_pane_spawn(struct window_pane *wp,
struct winsize ws;
int mode;
const char **envq;
struct timeval tv;
if (wp->fd != -1)
close(wp->fd);
@ -566,6 +550,13 @@ window_pane_spawn(struct window_pane *wp,
ws.ws_col = screen_size_x(&wp->base);
ws.ws_row = screen_size_y(&wp->base);
wp->window->pgrp = -1;
if (gettimeofday(&wp->window->name_timer, NULL) != 0)
fatal("gettimeofday");
tv.tv_sec = 0;
tv.tv_usec = NAME_INTERVAL * 1000L;
timeradd(&wp->window->name_timer, &tv, &wp->window->name_timer);
switch (forkpty(&wp->fd, NULL, NULL, &ws)) {
case -1:
return (1);