Operating System - HP-UX
1753549 Members
5544 Online
108795 Solutions
New Discussion юеВ

Re: retrieve absolute path from pid

 
SOLVED
Go to solution
RAC_1
Honored Contributor

Re: retrieve absolute path from pid

Finally Bill talked about option -x for ps command. You need to have ps patch for it. Else you can use UNIX95 command. Also as explained earlier by few memebers, if you started the progrm with absolute path, you will get it, else not.

ps -efx|grep "xyz"
UNIX95= ps -ef -o "ruser,args,pid" | grep "xyz"

Anil
There is no substitute to HARDWORK
Patrick Wallek
Honored Contributor

Re: retrieve absolute path from pid

Bill said it all. The full path is only stored if the process is started that way.
ranganath ramachandra
Esteemed Contributor
Solution

Re: retrieve absolute path from pid

i got the filename from the program below, on 11.00, 11.11 and 11.23.

---
#include
#include

int main (int argc, char *argv[])
{
struct pst_vm_status vmstat;
struct pst_filedetails psfdetails;
char name[1024];
int ret;
int pid = atoi(argv[1]);

/* last parameter to getprocvm is 1 */
/* because it worked :P will confirm */
/* with vm folks later */
if ((ret = pstat_getprocvm(&vmstat, sizeof(vmstat), pid, 1)) <0) {
perror("pstat_getprocvm");
exit(10);
}

if ((ret=pstat_getfiledetails(&psfdetails, sizeof(psfdetails),&(vmstat.pst_fid))) <0) {
perror("pstat_getfiledetails");
exit(20);
}

// printf ("device: %d, inode: %u\n", psfdetails.psfd_rdev, psfdetails.psfd_ino);

if ((ret=pstat_getpathname(name, 256, &(vmstat.pst_fid))) <0) {
perror("pstat_getpathname");
exit(30);
}

puts(name);
}
---
 
--
ranga
[i work for hpe]

Accept or Kudo

ranganath ramachandra
Esteemed Contributor

Re: retrieve absolute path from pid

oops i meant to say 11.11 and 11.23 but not on 11.00.
 
--
ranga
[i work for hpe]

Accept or Kudo

Senthilprakash_1
New Member

Re: retrieve absolute path from pid

Thanks, the program works :)
Prashant Zanwar_4
Respected Contributor

Re: retrieve absolute path from pid


This is to track down the childs.

Hope it helps..

/bin/ps -ef | awk -v v= ' ($3 == v) { print $2 } '

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."