TSR programs

hi
I want to write a tsr routine which use to replace the screen saver
program, is it possible in unix? how to write a tsr in UNIX?
what is address of screen saver program so that i can replace
my routine in that address.

TSR, as in Terminate and Stay Resident?
What exactly are you trying to accomplish with this?

Hi
Actually i want to shutdown all the terminals if user has not
touched the keyboard for 15 or 20 minutes , so only i want the
screen saver routine address so that i can repalce with my routine.

hi
actually i want to shutdown all the terminals if the user has not
touched the keyboard for 15 or 20 minutes , so only i want the address of screen saver routine so that i can replace with my routine.

Well, this could more easily be done, in my non-experienced opinion. Why not simply kill off any user / terminal after a certain amount of time? Or modify the screensaver / xlock utility to quit and kill all other processes (source for many versions of these are available)?
Or, you could install idled, which does it all for you?
http://www.darkwing.com/idled/

I figure, why re-write the wheel?
Besides, I don't think the screensaver is at any given "address"... Unix is not DOS, and will load programs into memory as needed and called - the memory address will change every time.
(Although I may be way off...)

Please keep this all in one area.
For everyone's reference, the original thread is here:

I merged the threads.

UNIX doesn't have a TSR concept. If you exit, the program dies. You can use facilities like select or signal to cause the program to wait for an event to occur.

UNIX typically runs on cpu's that have a MMU. In this case the address of every process is 0. Each process gets its own address space.

You need to define what you mean by "shutting down a terminal". My X terminal is on my desk. If I open a session to a computer in, say, Europe, that remote system has no way to know that I may also have session open to a system in Japan. Nor do either system have the power to shutdown my x terminal.

What the remote systems can do is to terminate my session if that session is idle for a length of time. You can write a daemon that scans for idle sessions and kills them. With most shells, you can also program them to terminate after a while. With ksh, you set the variable called TMOUT to do this.