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
--
Reporter (to Mahatma Gandhi): Mr Gandhi, what do you think of Western
Civilization?
Gandhi: I think it would be a good idea.
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.
Who will do the assignment? The kernel?
Binary Chen
"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-----
Thanks.
Binary CHEN
Woody is ancient. On sid:
ptmx (4) - pseudo-terminal master and slave
ptmx and pts (4) [ptmx] - pseudo-terminal master and slave
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