[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

8601.0. "Pseudo TTY to Socket information" by MARVIN::GOUGH (Raoul Gough) Mon Jan 27 1997 12:50

Hello,

Can anybody suggest how to identify the socket that's connected to a pseduo-
tty device?

ie.

$ who
myname      ttyp0       Jan 16 13:03         
theirname   ttyp1       Jan 16 13:04         
yourname    ttyp2       Jan 17 06:52         

$ netstat
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp        0      0  leslie.telnet          dhcpar1a.1028          ESTABLISHED
tcp        0      0  leslie.telnet          gimli.1110             ESTABLISHED
tcp        0      0  leslie.telnet          andrew.2598            ESTABLISHED

But which one is which?  How about xterms as well? (coming in on the .exec
port instead of .telnet)

Thanks,
Ray.
T.RTitleUserPersonal
Name
DateLines
8601.1SMURF::MENNERit's just a box of Pax..Mon Jan 27 1997 13:196
    A sockets are not directly connected to pseudo terminals.  The marriage
    happens in user space by a controlling process (e.g., telnetd) which
    has both a network stream (i.e., a socket open) and a master pty.
    The process reads from the socket and writes to the master (and
    vide versa).  Finding which process has the socket and which has
    what master pty is non trival.
8601.2File usage available, how bout the socket?MARVIN::GOUGHRaoul GoughMon Jan 27 1997 14:3811
Thanks for the response,
         <<< Note 8601.1 by SMURF::MENNER "it's just a box of Pax.." >>>


I've tried using fuser.c (see note 4183.2), which can identify the processes
using the /dev/ttyp.. pseudo device.  Is there any way to see the PIDs using
a socket?  I've got a bad feeling that it's one of those "Use kdbx" things.

Thanks,
Ray.
8601.3KITCHE::schottEric R. Schott USG Product ManagementMon Jan 27 1997 17:274
lsof ?

http://www-unix.zk3.dec.com/tuning/tools/tools.html

8601.4lsof is coolMARVIN::GOUGHRaoul GoughTue Jan 28 1997 04:5119
Re:<<< Note 8601.3 by KITCHE::schott "Eric R. Schott USG Product Management" >>>


Thanks Eric,

lsof does the job alright.  The only tricky bit is finding the controlling
process on the ttyp.. device and then looking at all the other files that the
process also has open.

More than one of them (?) is the socket connection, which is nicely listed
with it's remote end identified.  Might be more than one copy of the socket
because the xterm has done some dup(2) with it or something.

Anyway, lsof does just what I wanted.


Regards,
Ray.
8601.5What about fingerNETRIX::&quot;[email protected]&quot;marvin::goughTue Feb 11 1997 11:5717
Well, I should probably have entered the request in a unix_beginners
conference, because finger gives me the information I wanted:

$ finger gough
Login name: gough                       In real life: Ray Gough
Directory: /usr/users/gough             Shell: /usr/bin/ksh
On since Feb 11 10:20:07
   on ttyr1 from andmen
No Plan.

It doesn't say which socket from the remote host, but at least it gives
the host name.

Apologies for the mis-posting,
Ray
[Posted by WWW Notes gateway]