--- rxvt-unicode/src/logging.C 2006/01/17 06:06:42 1.25 +++ rxvt-unicode/src/logging.C 2006/01/17 10:59:32 1.29 @@ -33,9 +33,9 @@ #include "../config.h" #include "rxvt.h" -#include "logging.h" +#include "ptytty.h" -#ifdef UTMP_SUPPORT +#if UTMP_SUPPORT #if HAVE_STRUCT_UTMP static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); @@ -57,8 +57,13 @@ * make and write utmp and wtmp entries */ void -rxvt_session::login (const char *pty, int cmd_pid, bool login_shell, const char *hostname) +rxvt_ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname) { + const char *pty = name; + + if (!pty || !*pty) + return; + this->cmd_pid = cmd_pid; this->login_shell = login_shell; @@ -222,10 +227,13 @@ * remove utmp and wtmp entries */ void -rxvt_session::logout () +rxvt_ptytty_unix::logout () { + if (!cmd_pid) + return; + #ifdef HAVE_STRUCT_UTMP - struct utmp *ut = &this->ut; + struct utmp *tmput, *ut = &this->ut; #endif #ifdef HAVE_STRUCT_UTMPX struct utmpx *tmputx, *utx = &this->utx; @@ -237,12 +245,8 @@ setutent (); strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id)); ut->ut_type = USER_PROCESS; - { - struct utmp *tmput = getutid (ut); - - if (tmput) /* position to entry in utmp file */ - ut = tmput; - } + if ((tmput = getutid (ut))) /* position to entry in utmp file */ + ut = tmput; ut->ut_type = DEAD_PROCESS; # else memset (ut->ut_name, 0, sizeof (ut->ut_name)); @@ -307,6 +311,8 @@ pututxline (utx); endutxent (); #endif + + cmd_pid = 0; } /* ------------------------------------------------------------------------- */