close(term->screen.respond);
close(screen->respond);
Exit(n)	int n;{	register TScreen *screen = &term->screen;#ifdef UTMP#ifdef USE_SYSV_UTMP#if defined(SVR4) || defined(SCO325)	struct utmpx utmp;	struct utmpx *utptr;#else	struct utmp utmp;	struct utmp *utptr;#endif	char* ptyname;	char* ptynameptr = 0;#if defined(WTMP) && !defined(SVR4) && !(defined(linux) && __GLIBC__ >= 2)	int fd;			/* for /etc/wtmp */	int i;#endif	/* don't do this more than once */	if (xterm_exiting)	    SIGNAL_RETURN;	xterm_exiting = True;#ifdef PUCC_PTYD	closepty(ttydev, ptydev, (resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN), Ptyfd);#endif /* PUCC_PTYD */	/* cleanup the utmp entry we forged earlier */	if (!resource.utmpInhibit#ifdef USE_HANDSHAKE		/* without handshake, no way to know */	    && added_utmp_entry#endif /* USE_HANDSHAKE */	    ) {	    ptyname = ttydev;	    utmp.ut_type = USER_PROCESS;	    if (PTYCHARLEN >= (int)strlen(ptyname))		ptynameptr = ptyname;	    else		ptynameptr = ptyname + strlen(ptyname) - PTYCHARLEN;	    (void) strncpy(utmp.ut_id, ptynameptr, sizeof(utmp.ut_id));	    (void) setutent();	    utptr = getutid(&utmp);	    /* write it out only if it exists, and the pid's match */	    if (utptr && (utptr->ut_pid == term->screen.pid)) {		    utptr->ut_type = DEAD_PROCESS;#if defined(SVR4) || defined(SCO325) || (defined(linux) && __GLIBC__ >= 2)		    utmp.ut_session = getsid(0);		    utmp.ut_xtime = time ((time_t *) 0);		    utmp.ut_tv.tv_usec = 0;#else		    *utptr->ut_user=0;		    utptr->ut_time = time((time_t *) 0);#endif		    (void) pututline(utptr);#ifdef WTMP#if defined(SVR4) || defined(SCO325)		    if (term->misc.login_shell)			updwtmpx(WTMPX_FILE, &utmp);#else#if defined(linux) && __GLIBC__ >= 2		    if (term->misc.login_shell)			updwtmp(etc_wtmp, &utmp);#else		    /* set wtmp entry if wtmp file exists */		    if (term->misc.login_shell &&			(fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {		      i = write(fd, utptr, sizeof(utmp));		      i = close(fd);		    }#endif#endif#endif	    }	    (void) endutent();	}#else	/* not USE_SYSV_UTMP */	register int wfd;	struct utmp utmp;	if (!resource.utmpInhibit && added_utmp_entry &&	    (!am_slave && tslot > 0 && (wfd = open(etc_utmp, O_WRONLY)) >= 0)){		bzero((char *)&utmp, sizeof(struct utmp));		lseek(wfd, (long)(tslot * sizeof(struct utmp)), 0);		write(wfd, (char *)&utmp, sizeof(struct utmp));		close(wfd);#ifdef WTMP		if (term->misc.login_shell &&		    (wfd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {			register int i;			(void) strncpy(utmp.ut_line, ttydev +			    sizeof("/dev"), sizeof (utmp.ut_line));			time(&utmp.ut_time);			i = write(wfd, (char *)&utmp, sizeof(struct utmp));			i = close(wfd);		}#endif /* WTMP */	}#endif	/* USE_SYSV_UTMP */#endif	/* UTMP */#ifndef AMOEBA        close(term->screen.respond); /* close explicitly to avoid race with slave side */#endif#ifdef ALLOWLOGGING	if(screen->logging)		CloseLog(screen);#endif#ifndef AMOEBA	if (!am_slave) {		/* restore ownership of tty and pty */		chown (ttydev, 0, 0);#if (!defined(__sgi) && !defined(__osf__))		chown (ptydev, 0, 0);#endif		/* restore modes of tty and pty */		chmod (ttydev, 0666);#if (!defined(__sgi) && !defined(__osf__))		chmod (ptydev, 0666);#endif	}#endif /* AMOEBA */	exit(n);	SIGNAL_RETURN;}