Use utempter to update utmp if it's around for configure, from madmaverick9 at

roxxmail dot eu.
pull/1/head
Nicholas Marriott 2014-02-24 23:07:22 +00:00
parent 488583dc8d
commit 4273c1b80e
4 changed files with 25 additions and 0 deletions

View File

@ -144,6 +144,13 @@ if test "x$found_curses" = xno; then
AC_MSG_ERROR("curses not found")
fi
# Look for utempter
AC_CHECK_HEADER(utempter.h, have_utempter=yes, have_utempter=no)
if test "x$have_utempter" = xyes; then
AC_DEFINE(HAVE_UTEMPTER)
LIBS="$LIBS -lutempter"
fi
# Check for b64_ntop.
AC_MSG_CHECKING(for b64_ntop)
AC_TRY_LINK(

View File

@ -361,6 +361,9 @@ server_destroy_pane(struct window_pane *wp)
old_fd = wp->fd;
if (wp->fd != -1) {
#ifdef HAVE_UTEMPTER
utempter_remove_record(wp->fd);
#endif
bufferevent_free(wp->event);
close(wp->fd);
wp->fd = -1;

4
tmux.h
View File

@ -32,6 +32,10 @@
#include <stdio.h>
#include <termios.h>
#ifdef HAVE_UTEMPTER
#include <utempter.h>
#endif
#include "array.h"
#include "compat.h"

View File

@ -779,6 +779,9 @@ window_pane_destroy(struct window_pane *wp)
evtimer_del(&wp->changes_timer);
if (wp->fd != -1) {
#ifdef HAVE_UTEMPTER
utempter_remove_record(wp->fd);
#endif
bufferevent_free(wp->event);
close(wp->fd);
}
@ -810,6 +813,9 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
char *argv0, paneid[16];
const char *ptr;
struct termios tio2;
#ifdef HAVE_UTEMPTER
char s[32];
#endif
if (wp->fd != -1) {
bufferevent_free(wp->event);
@ -886,6 +892,11 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
fatal("execl failed");
}
#ifdef HAVE_UTEMPTER
xsnprintf(s, sizeof s, "tmux(%lu):%%%u", (long) getpid(), wp->id);
utempter_add_record(wp->fd, s);
#endif
setblocking(wp->fd, 0);
wp->event = bufferevent_new(wp->fd,