*BSD News Article 26242


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!news.uoknor.edu!ns1.nodak.edu!netnews.nwnet.net!news.clark.edu!lclark!news.reed.edu!walt.ee.pdx.edu!cs.uoregon.edu!sgiblab!sdd.hp.com!cs.utexas.edu!howland.reston.ans.net!agate!headwall.Stanford.EDU!rutgers!att-out!undergrad.math.uwaterloo.ca!mskucher
From: mskucher@after.math.uwaterloo.ca (Murray S. Kucherawy [MFCF])
Newsgroups: comp.unix.bsd
Subject: Finding controlling terminal for a process
Message-ID: <CJw7DE.9qH@undergrad.math.uwaterloo.ca>
Date: 19 Jan 94 19:56:02 GMT
Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
Organization: MFCF Special Weapons and Tactics
Lines: 18

Given the proc structure for a process, how can I determine which
device it's connected to?

What I'm trying: I'm looking at everything in /dev that's a character
device, stat()ing it, and remembering what st_rdev contains for
each.  Then, I'm looking through that list for a value that
matches u_ttyd for the process whose proc structure I have, and
trying to find a match.  In almost all cases, the match isn't
found, though since the structure refers to an interactive process,
it has to have a controlling terminal.

What am I doing wrong?

-- Murray S. Kucherawy ----------------------------------------+---------------
Software Systems Co-op, Math Faculty Computing Facility [MFCF] | Welcome to all
University of Waterloo, Ontario, Canada    +-------------------+ things UNIX -
E-mail: mskucherawy@math.UWaterloo.ca      | where if it's not UNIX, it's crap!
-------------------------------------------+-----------------------------------