0

Using this answer https://unix.stackexchange.com/a/283521/114939 which allow us to find processes that keep an given pty opened without login (who command cannot show them), caused me to ask the inverse.

How to get the opened pty(s) for a given process in AIX systems ? (for those launched in background and not "attached" to a terminal/pty login).

  • Did you try lsof or fuser? – Lucas May 17 '16 at 13:21
  • fuser in my case (AIX systems) doesn't shows files for a given process, but the inverse, processes for a given file. – Luciano May 17 '16 at 13:32
  • Yes but we have file globbing: fuser /dev/tty* /dev/pts/*. – Lucas May 17 '16 at 18:58
4

AIX has a /proc filesystem (since about 5.1?) and you can list the open file descriptors for a pid with procfiles:

$ procfiles -n 15502
15502 : /home/guest/test 
  Current rlimit: 2000 file descriptors                                 
   0: S_IFCHR mode:0622 dev:10,4  ino:2584 uid:100 gid:100 rdev:28,1
  O_RDONLY
   1: S_IFCHR mode:0622 dev:10,4  ino:2584 uid:100 gid:100 rdev:28,1
  O_RDONLY
   2: S_IFCHR mode:0622 dev:10,4  ino:2584 uid:100 gid:100 rdev:28,1
  O_RDONLY
   3: S_IFREG mode:0644 dev:10,7  ino:26 uid:100 gid:100 rdev:0,0       
  O_RDONLY size:0  name:/tmp/foo

For open devices like a pty only the inode and major/minor numbers are given, but you should be able to easily match these with those shown by a simple ls -l /dev/pts/.

You can also install the AIX Toolbox for Linux Applications and then use the lsof command.

0

If XXX is the pid

file /proc/XXX/fd/* | grep /dev/pt

But you will get multiple lines per pty if the process has it open for multiple roles (like stdin stdout and stderr)

But I guess this won't help for AIX vs Linux, unless AIX has changed a lot since I last used it

  • Sorry, I forgot to say that there is an AIX system (not Linux). – Luciano May 17 '16 at 13:48
  • yeah, I revised the answer when I saw one of your other comments, and then came back saw this one – infixed May 17 '16 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.