*BSD News Article 25281


Return to BSD News archive

Xref: sserve comp.unix.ultrix:20822 comp.unix.bsd:13175 comp.unix.programmer:13856 comp.unix.questions:43468
Path: sserve!newshost.anu.edu.au!munnari.oz.au!bunyip.cc.uq.oz.au!harbinger.cc.monash.edu.au!yeshua.marcam.com!news.kei.com!sol.ctr.columbia.edu!howland.reston.ans.net!gatech!concert!news.duke.edu!gallatin
From: gallatin@isds.duke.edu (Andrew Gallatin)
Newsgroups: comp.unix.ultrix,comp.unix.bsd,comp.unix.programmer,comp.unix.questions
Subject: Re: how to get a proc's tty info
Message-ID: <25637@news.duke.edu>
Date: 22 Dec 93 20:23:50 GMT
References: <25611@news.duke.edu>
Sender: news@news.duke.edu
Followup-To: comp.unix.ultrix
Organization: Duke University; Durham, N.C.
Lines: 16
Nntp-Posting-Host: serov.isds.duke.edu

In article <25611@news.duke.edu> gallatin@davinci.isds.duke.edu (Andrew Gallatin) writes:
>
>My problem is: Given a process id, or a proc struct, how can one get
>the controlling tty?  
>

The anwser turns out to be:

Use the address of the ttyp pointer from the proc struct, then lseek
and read it from kmem.  This struct will have an entry to the tty
device number, which can be matched to the name using stat().

Thanks to those who replied, epscially Alan Rollow,Mark Hahn, and Jim
Boyle.