Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How GNOME terminal works

4 views
Skip to first unread message

Binary

unread,
Dec 21, 2005, 10:11:13 PM12/21/05
to
Hi,

In GNOME terminal, I type 'tty' and get a result:

/dev/pts/0

This is a UNIX98 pty slave, and where to find the master and who open
the master?

Another question, how to find which process open a file named 'abc'.

grep 'abc' /proc/* -nr will block when encounters some device...

Binary

Bill Marcum

unread,
Dec 22, 2005, 12:34:27 AM12/22/05
to
On 21 Dec 2005 19:11:13 -0800, Binary
<binar...@gmail.com> wrote:
> Hi,
>
> In GNOME terminal, I type 'tty' and get a result:
>
> /dev/pts/0
>
> This is a UNIX98 pty slave, and where to find the master and who open
> the master?
>
> Another question, how to find which process open a file named 'abc'.
>
man fuser
man lsof


--
Reporter (to Mahatma Gandhi): Mr Gandhi, what do you think of Western
Civilization?
Gandhi: I think it would be a good idea.

Kasper Dupont

unread,
Dec 22, 2005, 3:15:58 AM12/22/05
to
Binary wrote:
>
> Hi,
>
> In GNOME terminal, I type 'tty' and get a result:
>
> /dev/pts/0
>
> This is a UNIX98 pty slave, and where to find the master and who open
> the master?

The master is /dev/ptmx. Each time somebody opens /dev/ptmx
a new slave is assigned. There is an ioctl you can use on
the fd for /dev/ptmx to get the name of your slave. But
that does not help much when looking on processes from the
outside trying to figure out which masters are conected to
which slaves. Luckily you will usually find, that each fd
for the master is held open by only one process, and it has
just one child which happens to have the slave open as fd
number 0, 1, and 2.

>
> Another question, how to find which process open a file named 'abc'.
>
> grep 'abc' /proc/* -nr will block when encounters some device...

That command makes no sense at all. Try this:
ls -ld /proc/*/fd/*|grep foobar

--
Kasper Dupont
Note to self: Don't try to allocate
256000 pages with GFP_KERNEL on x86.

Binary

unread,
Dec 22, 2005, 8:16:21 AM12/22/05
to
>Each time somebody opens /dev/ptmx a new slave is assigned.

Who will do the assignment? The kernel?

Binary Chen

Roger Leigh

unread,
Dec 22, 2005, 12:03:22 PM12/22/05
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Binary" <binar...@gmail.com> writes:

>>Each time somebody opens /dev/ptmx a new slave is assigned.
>
> Who will do the assignment? The kernel?

Yes. See ptmx(4), posix_openpt(3), grantpt(3), unlockpt(3),
ptsname(3). However, for typical usage openpty(3) and forkpty(3) are
all you need (but are BSD- and Linux- specific).


Regards,
Roger

- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iD8DBQFDqtxZVcFcaSW/uEgRAlP8AKDxpHEEs7k9FJQhJscBFZlQMt8iQQCgiQvH
SpHA9HCJR+P46UFjZ0hvpzA=
=16N5
-----END PGP SIGNATURE-----

Binary

unread,
Dec 22, 2005, 10:29:27 PM12/22/05
to
There is no man ptmx in my Debian Woody

Thanks.

Binary CHEN

Russell Shaw

unread,
Dec 23, 2005, 1:28:46 AM12/23/05
to
Binary wrote:
> There is no man ptmx in my Debian Woody

Woody is ancient. On sid:

ptmx (4) - pseudo-terminal master and slave
ptmx and pts (4) [ptmx] - pseudo-terminal master and slave

Kasper Dupont

unread,
Dec 23, 2005, 5:03:05 AM12/23/05
to
Binary wrote:
>
> >Each time somebody opens /dev/ptmx a new slave is assigned.
>
> Who will do the assignment? The kernel?

It is done by the driver, which is a part of the kernel.

You may find this a little help:
http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#ptmx

0 new messages