Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!natinst!uudell!sequoia!rpp386!jfh From: jfh@rpp386.cactus.org (John F Haugh II) Newsgroups: comp.unix.aix Subject: Re: Wierd problem with who and finger... Message-ID: <19129@rpp386.cactus.org> Date: 28 Mar 91 16:43:53 GMT References: <1991Mar25.164317.9775@rs6000.cmp.ilstu.edu> Reply-To: jfh@rpp386.cactus.org (John F Haugh II) Organization: Lone Star Cafe and BBS Service Lines: 52 X-Clever-Slogan: Recycle or Die. In article <1991Mar25.164317.9775@rs6000.cmp.ilstu.edu> dbeedle@rs6000.cmp.ilstu.edu (Dave Beedle) writes: > Hi all. I've got a strange problem going on with AIX 3003. When I do >a who or an Finger I see one user (not the same all the time) who appears >to have been logged on for 26 (or more) days. The user is not currently >logged on and has no processes running. What is going on? We recently >installed xwindows, pcsim, AIX access, and a compiler or two. I've mentioned this several times, so here is the source code. This code is being provided without warrantee (or even a copyright notice). Use it at your own risk. Compile this program with "cc -o /etc/utmpd utmpd.c" and run in the background with "nohup /etc/utmpd < /dev/null > /dev/null 2>&1 &" from your /etc/rc file. I use it on this system to clean up utmp file entries left over from various programs that create sessions on pty devices. DISCLAIMER: I speak for myself only. My employers are not responsible for what I post here and will not provide support for this code or anything it may do to your system. Use at your own risk. -- ---- begin utmpd.c ---- #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); } } ---- end utmpd.c ---- -- John F. Haugh II | Distribution to | UUCP: ...!cs.utexas.edu!rpp386!jfh Ma Bell: (512) 832-8832 | GEnie PROHIBITED :-) | Domain: jfh@rpp386.cactus.org "I want to be Robin to Bush's Batman." -- Vice President Dan Quayle