Re: HP-UX 11i how to retrieve long command line of process with C
From: Mike Stroyan (stroyan_at_hpstryn.fc.hp.com)
Date: 06/25/04
- Previous message: Jerry: "Install Tree Foo"
- In reply to: Mike Arnold: "HP-UX 11i how to retrieve long command line of process with C"
- Next in thread: Mike Arnold: "Re: HP-UX 11i how to retrieve long command line of process with C"
- Reply: Mike Arnold: "Re: HP-UX 11i how to retrieve long command line of process with C"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 25 Jun 2004 19:58:42 GMT
Mike Arnold <marnol01@mail.win.org> wrote:
|Under HP-UX 11i (and apparently 11.0 with patches PHKL_28202,
|PHKL_26008, and PHCO_26274), the -x option of the ps command can
|display 1020 characters of the command line of a process, a vast
|improvement compared to the previous 63-character limit.
|Does anyone know the underlying C statements to accomplish this? All
|my attempts to use pstat_getproc(2) still return only 63 characters,
|and the pst_cmd element of the pst_status structure is still defined
|as only 64 characters (via PST_CLEN). Recently, I received a hint
|that I might have to use the UNIX95 environment variable. If that is
|true, then I must be using it incorrectly because it hasn't helped.
A patched ps on 11i v1 uses pstat_getcommandline(). That is not
available as a documented and supported interface until 11i v1.6 or 11i v2.
You can read about the call in the system calls section of
http://www.docs.hp.com./hpux/onlinedocs/B2355-60103/B2355-60103.html
Here is an example using an unsupported interface on HP-UX 11.11 from
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=349348
#include <sys/pstat.h>
#include <sys/pstat/pstat_ops.h>
#define MAX_LENGTH (1024)
main (argc, argv) int argc; char *argv[]; {
int pid;
char long_command [MAX_LENGTH];
union pstun pu;
pid = atoi(argv[1]);
pu.pst_command = long_command;
if (pstat(PSTAT_GETCOMMANDLINE, pu, MAX_LENGTH, 1, pid) == -1) {
printf("ERROR: pstat() failure using pid(%d)\n", pid);
exit(-1);
}
printf("pid %d = %s\n", pid, pu.pst_command);
}
-- Mike Stroyan, mike.stroyan@hp.com
- Previous message: Jerry: "Install Tree Foo"
- In reply to: Mike Arnold: "HP-UX 11i how to retrieve long command line of process with C"
- Next in thread: Mike Arnold: "Re: HP-UX 11i how to retrieve long command line of process with C"
- Reply: Mike Arnold: "Re: HP-UX 11i how to retrieve long command line of process with C"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|