home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!csus.edu!csusac!cindy!rat!zeus!ctuel
- From: ctuel@zeus.calpoly.edu (Cliff Tuel)
- Newsgroups: comp.unix.questions
- Subject: Re: Changing Idle Time
- Message-ID: <1992Jul29.200554.180990@zeus.calpoly.edu>
- Date: 29 Jul 92 20:05:54 GMT
- References: <19115@fritz.filenet.com>
- Organization: Cal Poly, San Luis Obispo
- Lines: 49
-
- scotth@fritz.filenet.com (Scott Hopson) said...
- |If you have people checking up on you by looking at your idle time
- |which is displayed by finger, then this might help. This program
- |constantly updates you terminal idle time so you appear to be working all the
- |time. This program runs as a daemon and updates any terminal you happen to
- |logon to. Have Fun....
-
- [ Program based on "utime(ttypath,NULL)" deleted ]
-
- Maybe this wasn't the intent of your program, but our local network kicks
- off anyone idle for more than 30 minutes, and changing the atime and mtime
- of the tty has no effect. You need to simulate terminal activity using
- "ioctl(1, TIOCSTI, s)". For example:
-
- void typestring (s)
- char *s;
- {
- while (*s) {
- ioctl(1, TIOCSTI, s);
- *s++;
- }
- ioctl(1, TIOCSTI, "^M");
- }
-
- Run this from a background process, first doing a "signal (SIGTTOU, SIG_IGN)"
- to allow writes from the background. Try stuff like: typestring ("uptime").
-
- Another thing to consider is to have the forked process commit suicide if
- you log out. Passing the shell's pid to the forked child is a little tricky
- but not impossible. Once you have the pid, you can do:
-
- if (kill (shellpid, 0) == -1)
- exit (1);
-
- Finally, you should watch the idle time on the tty, and only call typestring()
- if the time is greater than some threshold:
-
- timenow = time ((time_t *) NULL);
- stat (ttyname, stbuf);
-
- if ((timenow - stbuf->st_mtime) > IDLETIME)
- typestring (s);
-
-
- --
- Cliff Tuel __o o__
- HP/Apollo System Admin \( v )/ YELLO & ART OF NOISE mailing lists:
- Cal Poly, San Luis Obispo /___\ Yello-request@polyslo.CSc.CalPoly.edu
- ctuel@nike.CalPoly.edu ^ ^ AoN-request@polyslo.CSc.CalPoly.edu
-