3

I tried ls -l /proc/17301504 there is no exe which gives me full path to command. Is there a way to get the full path of command in Aix 5 and above as in Linux?

There is a.out in /proc/17301504/object which has same checksum as the command, but does not gives the full path.

2

The /proc filesystem is inherently not portable between operating systems. There are Unices where it does not exist at all.

The /proc filesystem on AIX is documented here: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.files/proc.htm

About the a.out file in the object subdirectory, it says:

[...] The name a.out also appears in the directory as a synonym for the executable file associated with the text of the running process.

The object directory makes it possible for a controlling process to get access to the object file and any shared libraries (and consequently the symbol tables), without the process first obtaining the specific path names of those files.

This means that accessing the a.out file in that structure is more or less the opposite of what you want to do. It allows a user program to access the executable of a process without knowing its full path.

There is also structures in /proc on AIX that contains the basename of the executable, but again, this is not what you're interested in.

Since a process can set its own zeroth command line argument (the name of the process that shows up in ps), using ps would also not be a surefire solution to find the absolute path to the running executable, even if it was executed with a full path.

What you could do is to hunt down the executable by its inode.

An example of how to do this is described in the currently accepted answer to the question "How to identify executable path with its PID on AIX 5 or more".

It may also be good to ask yourself why you need this information from querying a running process, as it's usually clear from studying a script or program exactly what external utilities it is invoking.

1

Get the inode and major/minor number with the istat command of /proc/<pid>/object/a.out:

$ istat a.out
Inode 4694 on device 10/5       File
Protection: r-xr-xr--   Set UID 
Owner: 0(root)          Group: 0(system)
Link count:   1         Length 82411 bytes

Last updated:   Fri May  4 13:58:53 PDT 2018
Last modified:  Wed Nov 29 10:40:56 PST 2017
Last accessed:  Wed Sep  5 14:51:07 PDT 2018

Get the file system name from the major/minor number

$ ls -l /dev/* | grep 10, | grep ' 5 '
brw-rw----    1 root     system       10,  5 Jul 03 2017  /dev/hd2
crw-rw----    1 root     system       10,  5 Jul 03 2017  /dev/rhd2

$ df /dev/hd2
Filesystem    512-blocks      Free %Used    Iused %Iused Mounted on
/dev/hd2        10944512   2220824   80%    41861     4% /usr

Get the file name from the inode

$ find /usr -inum 4694 -exec /bin/ls -l {} \;
-r-sr-xr--    1 root     system        82411 Nov 29 2017  /usr/sbin/inetd

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.