void done(void) { time_t tvec; if (subchild) { if (!qflg) { char buf[BUFSIZ]; tvec = time((time_t *)NULL); my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec)); fprintf(fscript, _("\nScript done on %s"), buf); } if (close_stream(fscript) != 0) errx(EXIT_FAILURE, _("write error")); close(master); master = -1; } else { tcsetattr(STDIN_FILENO, TCSADRAIN, &tt); if (!qflg) printf(_("Script done, file is %s\n"), fname); #ifdef HAVE_LIBUTEMPTER if (master >= 0) utempter_remove_record(master); #endif } if(eflg) { if (WIFSIGNALED(childstatus)) exit(WTERMSIG(childstatus) + 0x80); else exit(WEXITSTATUS(childstatus)); } exit(EXIT_SUCCESS); }
void done() { time_t tvec; if (subchild) { if (!qflg) { char buf[BUFSIZ]; tvec = time((time_t *)NULL); my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec)); fprintf(fscript, _("\nScript done on %s"), buf); } (void) fclose(fscript); (void) close(master); master = -1; } else { (void) tcsetattr(0, TCSADRAIN, &tt); if (!qflg) printf(_("Script done, file is %s\n"), fname); #ifdef HAVE_LIBUTEMPTER if (master >= 0) utempter_remove_record(master); #endif } if(eflg) { if (WIFSIGNALED(childstatus)) exit(WTERMSIG(childstatus) + 0x80); else exit(WEXITSTATUS(childstatus)); } exit(0); }
static void __attribute__((__noreturn__)) done(struct script_control *ctl) { DBG(MISC, ul_debug("done!")); if (ctl->isterm) tcsetattr(STDIN_FILENO, TCSADRAIN, &ctl->attrs); if (!ctl->quiet) printf(_("Script done, file is %s\n"), ctl->fname); #ifdef HAVE_LIBUTEMPTER if (ctl->master >= 0) utempter_remove_record(ctl->master); #endif kill(ctl->child, SIGTERM); /* make sure we don't create orphans */ if (ctl->timingfp) fclose(ctl->timingfp); fclose(ctl->typescriptfp); if (ctl->rc_wanted) { if (WIFSIGNALED(ctl->childstatus)) exit(WTERMSIG(ctl->childstatus) + 0x80); else exit(WEXITSTATUS(ctl->childstatus)); } exit(EXIT_SUCCESS); }
int utempter_remove_added_record(void) { if (saved_fd < 0) return 0; else return utempter_remove_record(saved_fd); }
/* EXTPROTO */ void rxvt_cleanutent(rxvt_t *r) { #ifdef UTEMPTER_SUPPORT utempter_remove_record (PVTS(r)->cmd_fd); #else /* UTEMPTER_SUPPORT */ #ifdef HAVE_STRUCT_UTMP struct utmp *ut = &(PVTS(r)->ut); #endif #if defined(HAVE_STRUCT_UTMPX) && !defined(HAVE_STRUCT_UTMP) struct utmpx *tmputx, *utx = &(PVTS(r)->utx); #endif #ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UTMP_PID MEMSET(ut, 0, sizeof(struct utmp)); setutent(); STRNCPY(ut->ut_id, PVTS(r)->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; } ut->ut_type = DEAD_PROCESS; # else MEMSET(ut->ut_name, 0, sizeof(ut->ut_name)); # ifdef HAVE_UTMP_HOST MEMSET(ut->ut_host, 0, sizeof(ut->ut_host)); # endif # endif ut->ut_time = time(NULL); #endif #if defined(HAVE_STRUCT_UTMPX) && !defined(HAVE_STRUCT_UTMP) MEMSET(utx, 0, sizeof(struct utmpx)); setutxent(); STRNCPY(utx->ut_id, PVTS(r)->ut_id, sizeof(utx->ut_id)); utx->ut_type = USER_PROCESS; if ((tmputx = getutxid(utx))) /* position to entry in utmp file */ utx = tmputx; utx->ut_type = DEAD_PROCESS; # ifdef HAVE_UTMPX_SESSION utx->ut_session = getsid(0); # endif utx->ut_tv.tv_sec = time(NULL); utx->ut_tv.tv_usec = 0; #endif /* * Write ending wtmp entry */ #ifdef WTMP_SUPPORT # ifdef WTMP_ONLY_ON_LOGIN if (ISSET_OPTION(r, Opt_loginShell)) # endif { # ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UPDWTMP updwtmp(RXVT_WTMP_FILE, ut); # else rxvt_update_wtmp(RXVT_WTMP_FILE, ut); # endif # endif # if defined(HAVE_STRUCT_UTMPX) && !defined(HAVE_STRUCT_UTMP) # ifdef HAVE_UPDWTMPX updwtmpx(RXVT_WTMPX_FILE, utx); # else pututxline (utx); # endif # endif } #endif /* * Write utmp entry */ #ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UTMP_PID if (ut->ut_pid == PVTS(r)->cmd_pid) pututline(ut); endutent(); # else MEMSET(ut, 0, sizeof(struct utmp)); rxvt_write_bsd_utmp(PVTS(r)->utmp_pos, ut); # endif #endif #if defined(HAVE_STRUCT_UTMPX) && !defined(HAVE_STRUCT_UTMP) if (utx->ut_pid == PVTS(r)->cmd_pid) pututxline(utx); endutxent(); #endif #endif /* UTEMPTER_SUPPORT */ }