how to get sessionID from controlling tty

how to get sessionID from controlling tty

Post by Sandeep Caria » Sat, 23 Apr 1994 08:31:51

        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
  kernel and
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


how to get sessionID from controlling tty

Post by Arun Bhal » Wed, 27 Apr 1994 11:22:23

I also need to know.


Arun Bhalla

 \ The above does not represent OIT, UNC-CH, laUNChpad, or its other users. /


1. Getting the real tty device name (/dev/tty not good enough)

Does anyone have any handy code that works on Sun to dope out the real
device name of the controlling terminal for a process? /dev/tty is just
not good enough for what I need to do.

Send mail to me and I will summarize.

Thanks in advance.


Olan           uucp: rutgers!bcm!sob             and Systems Support
Barber         Opinions expressed are only mine. Baylor College of Medicine

2. PPP connection using Redhat linux 4.1

3. Menus for both cursor control and tty?

4. suse 6.3 Alpha-axp troubles

5. How does flow control work for pseudo ttys under HP-UX?

6. serial problems with 1.1.5?

7. controlling tty info

8. LDAP for Linux and NT

9. Help with tty control

10. Controlling tty problem

11. tty control under c - help needed

12. Controlling TTY

13. tty not a typewriter (No job control).