Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Proc::ProcessTable truncating cmndline and fname

by rgren925 (Beadle)
on Feb 12, 2016 at 00:24 UTC ( #1155023=perlquestion: print w/replies, xml ) Need Help??

rgren925 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monks.

I am using Proc::ProcessTable and am having problems on Solaris and HP-UX where the cmndline value is being truncated at 80 and 64, respectively.

In addition, the fname is being truncated at 16 and 15, respectively.

All is working fine on AIX and Linux (RHEL).

Any ideas? Thanks. Rick

  • Comment on Proc::ProcessTable truncating cmndline and fname

Replies are listed 'Best First'.
Re: Proc::ProcessTable truncating cmndline and fname
by jcb (Parson) on Feb 12, 2016 at 01:47 UTC

    Does ps(1) also truncate at the same points? The kernel might only store so many characters or the regular API for retrieving process information only return a fixed-width field.

    While looking up CPAN docs for Proc::ProcessTable, I found P9Y::ProcessTable, which seems to be a pure-Perl attempt at a similar module. Reading its code suggests that Solaris puts the command line and the filename in fixed-width fields in a "psinfo" file. I suspect that ps(1) will have the same problem and that you have encountered kernel limitations on Solaris and HP-UX.

    Further digging into the Proc::ProcessTable source shows that the HP-UX and Solaris ports more-or-less directly return information from the kernel. Unless there are other ways to get the command line and filename, I think that you are stuck.

    Look around in /proc/<PID>. On Linux, for example, the overall process status file contains only a command name, but the entire argv array is in cmdline.

      Good call on Solaris. ps(1) truncates exactly the same way.
      So, how does "/usr/ucb/ps auxww" get the full command line if not from the kernel?

      Not the same for HP-UX. though.
      ps(1) returns far more than Proc::ProcessTable.
      I'm wondering if there is a way to configure this so I get back at least what ps gives me.

        In both cases, more information is available, but Proc::ProcessTable does not know how to retrieve it.

        You will need to find where ps(1) gets its information and then submit patches for Proc::ProcessTable. A good first place to look is /proc/<PID>. There may be additional files in there with useful information; this is certainly the case on Linux. Unfortunately, I don't have Solaris or HP-UX close at hand, so I can really only speculate on what you will need.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1155023]
Approved by Paladin
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2023-12-09 11:48 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (38 votes). Check out past polls.