Search code examples
linuxshellunixprocesssolaris

Simplest way of determining process bitness on Solaris and Linux


I'm looking for a simple and reliable way of determining the bitness of a running process using standard shell commands.

While I've seen solution for Solaris and Linux I'd like to find one solution that works for both for extra simplicity, reliability and portability.

In Linux this can be done using /proc/$PID/exe, /proc/$PID/maps, /proc/$PID/auxv for example but these methods are either not present on Solaris or cannot easily be invoked from sh.

In Solaris a way of doing this is pflags $PID however pflags is not installed on most stock Linux distributions.


Solution

  • On Solaris, the utility /bin/pflags will give you the information you need:

        $ /bin/pflags $$ | fgrep "data model"
                data model = _ILP32  flags = ORPHAN|MSACCT|MSFORK
    

    _ILP32 is a 32-bit process, while _LP64 is a 64-bit process.

    On Linux, there is nothing directly similar. You may want to check the very complete answer there: https://unix.stackexchange.com/questions/106234/determine-if-a-specific-process-is-32-or-64-bit