I'm writing a program that will ask for a tolerable amount of idle time,
search /etc/utmp for all ttys that have been idle for more than the
"tolerable amount of idle time", and then kill all processes associated
with that tty. But to complete this program, I have a question for which
I cannot get a resolution given the resources I have:
Given a tty, how do you get the controlling process for it? In the UNIX
process architecture, there is one process in a login session that
controls the tty. Killing this process means that all its children are
killed as well.
According to the SUN manuals, the controlling process for a tty is
the same as a session leader for the tty, so getting the session leader
for the tty should be enough. Solaris 2.x has a way of doing this
(using getsid(2)), but I was not able to find an equivalent way of doing
this in SUNOS4.x. I know there is no system call that can get this info
for me, but is there some way I can extract this info directly from the
kernel itself? There *has* to be some way of figuring this out, because
ps does it.
In a more general sense, is there some way I can get:
a.The names of all the data structures that reside within a running
b.Ways to extract their values?
Any responses would be greatly appreciated!
If you can't dazzle them with brilliance, baffle them with bullshit.
-- Ernest Hemingway