Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!chinacat!sequoia!rpp386!jfh From: jfh@rpp386.cactus.org (John F Haugh II) Newsgroups: comp.unix.aix Subject: Re: utmp fix? Message-ID: <19352@rpp386.cactus.org> Date: 2 Jun 91 04:23:54 GMT References: <1991May30.011132.28981@magnus.acs.ohio-state.edu> Reply-To: jfh@rpp386.cactus.org (John F Haugh II) Organization: Lone Star Cat Emporium and BBQ Grill Lines: 41 X-Clever-Slogan: Help Prevent Robbery. Tax the IRS. In article <1991May30.011132.28981@magnus.acs.ohio-state.edu> mcover@magnus.acs.ohio-state.edu (Mark Coverdill) writes: > I typed in a program I saw about two weeks back to fix this >problem but that had no effect and have been unable to locate it >in various archives. Soooo, if someone would kindly repost the >entire procedure on how to do this or tell me where I can ftp >the procedure to cleanup the utmp file I would appreciate it. This is a program that I use here to keep my utmp file clean. I posted it once before and someone at IBM brushed it up and made it look pretty. Here it is again ... -- #include #include #include main () { int fd; struct utmp utmp; while (1) { if ((fd = open ("/etc/utmp", O_RDWR)) < 0) exit (1); while (read (fd, &utmp, sizeof utmp) == sizeof utmp) { if (utmp.ut_type == USER_PROCESS && kill (utmp.ut_pid, 0) != 0) { lseek (fd, - (long) sizeof utmp, 1); utmp.ut_type = DEAD_PROCESS; write (fd, &utmp, sizeof utmp); } } close (fd); sleep (60); } } -- John F. Haugh II | Distribution to | UUCP: ...!cs.utexas.edu!rpp386!jfh Ma Bell: (512) 255-8251 | GEnie PROHIBITED :-) | Domain: jfh@rpp386.cactus.org "If liberals interpreted the 2nd Amendment the same way they interpret the rest of the Constitution, gun ownership would be mandatory."