Operating System - HP-UX
1752794 Members
6272 Online
108789 Solutions
New Discussion юеВ

Re: pstat_getcommandline() link error ??

 
Ma_Ta
Occasional Advisor

pstat_getcommandline() link error ??

Hello.
I'm a begginer on HP-UX's C programmings
and environment.

I wrote a program(bsntest.c) as below:

include <STDIO.H>
#include
#include <UNISTD.H>

main(){
char buf[1024+1];
int pid;
pid = (int) getpid();
puts("use pstat_commandline()");
pstat_getcommandline(buf,1024,1,pid);

printf("command line : %s", buf);
}

when I did "cc bsntest.c",
then the error messages displayed as bellow:

$ cc bsntest.c
/usr/ccs/bin/ld: Unsatisfied symbols:
pstat_getcommandline (first referenced in bsntest.o) (code)

I guess that something is wrong to link,
but I can't understand the details of ld at now.(ofcource, I read ld's man page..)

Please tell me how to solve this problem.

regards,
Takanobu Maekawa

 

 

Moved from HP-UX Technical Documentation to HP-UX > languages

2 REPLIES 2
Ermin Borovac
Honored Contributor

Re: pstat_getcommandline() link error ??

pstat_getcommandline() is not available as a documented and supported function until 11i v2. Assuming that you are on 11i v1 you can use the following code to get up to 1024 characters of the command line of a process.

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

Ma_Ta
Occasional Advisor

Re: pstat_getcommandline() link error ??

Thanks very much!
the probrem has removed!

regards,
Takanobu Maekawa