[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hpux-devtools
Subject:    Re: HPUX-DEVTOOLS: Long command line and pstat_getproc()
From:       Eric Gouriou <eric.gouriou () hp ! com>
Date:       2004-01-12 23:09:25
Message-ID: 40032925.4040601 () hp ! com
[Download RAW message or body]

Michael Goltsman wrote:
> I need to get long (more than 128 chars) command lines out of
> pstat_getproc(). Currently pst_cmd is 64 bytes long and pst_ucomm is 17
> bytes long.
> I know It's possible as ps(1) does it in UNIX95 mode on the same
> machine.
> 
> What should I do?

  See the mail I append below. If I remember correctly the lack of
documentation for pstat_commandline / PSTAT_GETCOMMANDLINE in 11.11
was just an oversight.

  I hope this helps,

    Eric

-- 
Eric Gouriou                                         eric.gouriou@hp.com


-------- Original Message --------
Subject: HPUX-DEVTOOLS: Re: CXX-DEV: How do I get to the commandline arguments of  anotherprocess
Date: Tue, 20 May 2003 14:02:49 -0700
From: Eric Gouriou <egouriou@cup.hp.com>
Organization: Hewlett Packard Company
To: Nukala, Vamsi <Vamsi.Nukala@compuware.com>
CC: HPUX Devtools <hpux-devtools@cxx.cup.hp.com>
References: <99EEA3013ED5D211A77F0008C71BCA8D07EF6A83@POSTOFFICE>

  Vamsi,

  Please keep using the lists, I'd prefer to keep such communications
in the open whenever possible.

"Nukala, Vamsi" wrote:
 > > Isn't 'ps -x' enough ?
 > No. The convenience structures that HP published was probably for PS use
 > only ( i.e. with 64B restriction ) I am looking for the entire command line
 > that was exec-ed.

  I do not see a 64B limit when running ps -x, and ps -x must be using
pstat. (more on that below)

 > The things I need (a vector of all the cmdline args, current working
 > directory)  will be present somewhere in the "proc" space.

  What do you mean by "proc" space ? "process", "/proc" ?

  The command line arguments and environment doesn't fully exist
in the kernel, for good reasons. Once a process is exec'ed, this data
resides in the process address space, hence it's not trivial
to access it.

  However I see a movement to have the kernel keep easy access to
more of that data, to allow more tools to be easily developed.
As a tool writer I am really happy with that change, however
I understand and respect the original design.

 > This is not published by HP.

  No, it doesn't seem to be published for 11i v1 (11.11).

  Here is a quick experiment run on a 11.11 system, using tusc:
---------
 > tusc ps -x
...
pstat(PSTAT_GETCOMMANDLINE, 0x40022580, 1024, 1, 27155) .. = 10
  27155 ttyp3     0:00 tusc ps -x
...
pstat(PSTAT_GETCOMMANDLINE, 0x40022988, 1024, 1, 27156) .. = 5
  27156 ttyp3     0:00 ps -x
...
---------

  Ahah, PSTAT_GETCOMMANDLINE !?

  Ok, PSTAT_GETCOMMANDLINE doesn't appear to be documented in the 11.11
headers. Bummer :-( . Yet sys/pstat/pstat_ops.h (included from <pstat.h>)
contains the constant PSTAT_GETCOMMANDLINE. So what is to stop us
to dig a bit ?

  What about boldly trying something like:
    char buffer[BUFF_SZ];
    nchar = pstat(PSTAT_GETCOMMANDLINE, buffer, BUFF_SZ, 1, pid);  ?

  It might just work ! I don't know for sure what the buffer size
limit is (but it could very well be 1020 bytes).

  And once you move to a later HP-UX, do a 'man pstat' to check
if maybe a 'pstat_commandline' didn't magically appear in the
documentation.

  Now I didn't tell you anything, it's certainly not supported,
I will deny ever talking to you, etc, etc... More seriously
I am not making any guarantee, and neither is HP. If the stability
of your machine is important, I'd advise you to ask the response
center about the status and documentation of PSTAT_GETCOMMANDLINE.

 > > Which system are you running on ?
 > 11i on PA RISC.
 >
 > Sorry, I directed my question at the wrong mailing list.

  No problem.

  Regards - Eric

-- 
Eric Gouriou                             egouriou@cup.hp.com
 _________________________________________________________________
 To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
    with the message UNSUBSCRIBE hpux-devtools
 _________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic