Operating System - HP-UX
1832990 Members
2783 Online
110048 Solutions
New Discussion

Re: question on pstat_getcommandline

 
SOLVED
Go to solution
Padmini_2
Occasional Advisor

question on pstat_getcommandline

Hi,
I am currently running on HPUX 11i. I am using pstat_getcommandline in one of my programs. I get the following error when I try to compile.
---------------------------
Function 'pstat_getcommandline' has not been defined yet; cannot call.
---------------------------
Even though I have included sys/pstat.h?

Could someone please help me out?

Thanks
Padmini
4 REPLIES 4
Adisuria Wangsadinata_1
Honored Contributor

Re: question on pstat_getcommandline

Hi there,

I can't see the option for 'pstat_getcommandline' from the manual page on HP-UX 11i system.

# man pstat

Could you inform to me what the purpose of 'pstat_getcommandline' in your script ?

Best Regards,
AW
now working, next not working ... that's unix
Padmini_2
Occasional Advisor

Re: question on pstat_getcommandline

Hi,
From the net I found pstat_getcommandline Returns the commandline of the process specified (which is listed for 11.i v2)
However, I am currently running on 11.11 (pa risc ). Does it mean, pstat_getcommandline for 11.11, is not supported?
And that pstat_getcommandline is only for 11.i v2 (for intel itanium 2 architecture)?

Thanks
Padmini

Jean-Louis Phelix
Honored Contributor
Solution

Re: question on pstat_getcommandline

You are right ... Unsupported ! From doc KBRC00006317 you can read :

...
The PSTAT_GETCOMMANDLINE opcode is undocumented and unsupported for normal use.
...
With these caveats in mind, here is sample C code that uses the PSTAT_GETCOMMANDLINE function code and works on an HP-UX 11.11 system as of March 28, 2001:

#include
#include
#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);
}
...

Regards.
It works for me (© Bill McNAMARA ...)
Padmini_2
Occasional Advisor

Re: question on pstat_getcommandline

Thanks Jean-Louis for the answer. This helped me solve the problem.