<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get full path of executable of running process... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135523#M689016</link>
    <description>If argv[0] is an absolute path, you are done.  If relative, you use getcwd(3) and concatenate.  Otherwise you  get getenv("PATH") and then stat(2) argv[0] concatenated to it.  And find the first that is executable and is a file.</description>
    <pubDate>Tue, 14 Oct 2008 20:28:56 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2008-10-14T20:28:56Z</dc:date>
    <item>
      <title>Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135520#M689013</link>
      <description>&lt;!--!*#--&gt;Hi All,&lt;BR /&gt;I want to get the full path of the running process (executable) without having root permission using C++ code. Can someone suggest a way to achieve this.&lt;BR /&gt;&lt;BR /&gt;on Linux platforms i can do it by using following way.&lt;BR /&gt;&lt;BR /&gt;char exepath[1024] = {0};&lt;BR /&gt;char procid[1024] = {0};&lt;BR /&gt;char exelink[1024] = {0};&lt;BR /&gt;&lt;BR /&gt;sprintf(procid, "%u", getpid());&lt;BR /&gt;&lt;BR /&gt;strcpy(exelink, "/proc/");&lt;BR /&gt;strcat(exelink, procid);&lt;BR /&gt;strcat(exelink, "/exe");&lt;BR /&gt;&lt;BR /&gt;readlink(exelink, exepath, sizeof(exepath));&lt;BR /&gt;&lt;BR /&gt;Here exepath gives us the full path of the  executable.&lt;BR /&gt;&lt;BR /&gt;Similarly for windows we do it using &lt;BR /&gt;GetModuleFileName(NULL, exepath, sizeof(exepath));  /* get fullpath of the service */&lt;BR /&gt;&lt;BR /&gt;Please help me how to do it on HP-UX since there is no /proc directory in HP-UX.</description>
      <pubDate>Tue, 14 Oct 2008 09:39:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135520#M689013</guid>
      <dc:creator>rakeshcs123</dc:creator>
      <dc:date>2008-10-14T09:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135521#M689014</link>
      <description>I am not sure, but, see if 'pstat_getcommandline()' is what you are looking for. Check out its man page for details.</description>
      <pubDate>Tue, 14 Oct 2008 09:56:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135521#M689014</guid>
      <dc:creator>Venkatesh BL</dc:creator>
      <dc:date>2008-10-14T09:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135522#M689015</link>
      <description>I see that there is a function pstat_getpathname() which returns the full pathname of the process but is limited to UID=0 , but my requirement is a non root user should be able to get the full path name of the executable from the process.</description>
      <pubDate>Tue, 14 Oct 2008 12:12:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135522#M689015</guid>
      <dc:creator>rakeshcs123</dc:creator>
      <dc:date>2008-10-14T12:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135523#M689016</link>
      <description>If argv[0] is an absolute path, you are done.  If relative, you use getcwd(3) and concatenate.  Otherwise you  get getenv("PATH") and then stat(2) argv[0] concatenated to it.  And find the first that is executable and is a file.</description>
      <pubDate>Tue, 14 Oct 2008 20:28:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135523#M689016</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-10-14T20:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135524#M689017</link>
      <description>Hi All, ACtually i don have option to append argv[0] to getcwd() output, because my code has to detect the excecutable path (which is running). my code to find the full executable path is in some shared library loaded by executable, so i dont really have argv[0] option to use. Only thing that i have is the process id, under which my shared library is loaded. so if someone can suggest a way to use process id and then from that find the executalbe full path, it would be great. As you can see in my initial description i have used way to find full path of executable using process id or directly with some system function (which also uses current process to return result). I see there is one function pstat_getpathname() available on hpux but is restricted to root or equivalent user, but my requirement is any user should be able to get the path (obviously user who is running the process).&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.</description>
      <pubDate>Wed, 15 Oct 2008 15:29:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135524#M689017</guid>
      <dc:creator>rakeshcs123</dc:creator>
      <dc:date>2008-10-15T15:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135525#M689018</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Stating the HP-UX *release* on which you are running would be useful.  The 'pstat()' module has more functionality in newer releases than in older ones.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 15 Oct 2008 15:41:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135525#M689018</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-15T15:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135526#M689019</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;as a try I would set the s-bit for root on the executable, which uses the function  pstat_getpathname() .&lt;BR /&gt;&lt;BR /&gt;It depends on other stuff done by this program, if that is a security risk.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Wed, 15 Oct 2008 16:14:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135526#M689019</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2008-10-15T16:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135527#M689020</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I don't really have argv[0] option to use.&lt;BR /&gt;&lt;BR /&gt;Sure you do, you just have to work smarter. :-)&lt;BR /&gt;Also, if you were using a real shell the variable "_" would have the relative or absolute path of the executable.  sh may not have the "./".&lt;BR /&gt;&lt;BR /&gt;&amp;gt;directly with some system function&lt;BR /&gt;&lt;BR /&gt;No such function for ordinary users.&lt;BR /&gt;&lt;BR /&gt;This program only shows you how to get argv:&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;CRT0.H&gt;  /* _environ, __argv (ELF) */&lt;BR /&gt;&lt;BR /&gt;#if defined(__LP64__) || defined(__ia64)&lt;BR /&gt;#define ARGVS __argv&lt;BR /&gt;#else&lt;BR /&gt;extern char **__argv_value;&lt;BR /&gt;#define ARGVS __argv_value&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;int main() {&lt;BR /&gt;   int i;&lt;BR /&gt;   const char *path = getenv("PATH");&lt;BR /&gt;   printf("PATH=%s\n", path);&lt;BR /&gt;   for (i = 0; ARGVS[i]; ++i) {&lt;BR /&gt;      printf("argv[%03d]: %s\n", i, ARGVS[i]);&lt;BR /&gt;   }&lt;BR /&gt;   for (i = 0; _environ[i]; ++i) {&lt;BR /&gt;      printf("env[%03d]: %s\n", i, _environ[i]);&lt;BR /&gt;   }&lt;BR /&gt;   return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;/CRT0.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 15 Oct 2008 19:20:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135527#M689020</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-10-15T19:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135528#M689021</link>
      <description>&lt;!--!*#--&gt;It seems either i should use pstat_getpathname() function or use getcwd()/argv[0].&lt;BR /&gt;&lt;BR /&gt;Signature of pstat_getpathname&lt;BR /&gt;int pstat_getpathname(&lt;BR /&gt;char *buf,&lt;BR /&gt;size_t elemcount,&lt;BR /&gt;struct pst_fid *fid&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;I see the man page of pstat_getpathname() which states we can use pstat_getfile2() or pstat_getproc() to obtain fid. but when i see  signature of pstat_getproc then it takes struct pst_status as an argument. how to get the fid from struct pst_status variable. &lt;BR /&gt;&lt;BR /&gt;from  pstat_getfile2 things works, but i need to open the file to get this details (which i dont have).&lt;BR /&gt;&lt;BR /&gt;Thanks in advance...</description>
      <pubDate>Thu, 16 Oct 2008 11:17:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135528#M689021</guid>
      <dc:creator>rakeshcs123</dc:creator>
      <dc:date>2008-10-16T11:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135529#M689022</link>
      <description>&amp;gt;but I need to open the file to get this details&lt;BR /&gt;&lt;BR /&gt;You don't know the name and it isn't open.  So you are left with getcwd()/argv[0].&lt;BR /&gt;&lt;BR /&gt;I suppose you could use shl_get(3) or dlget(3) and then use advanced AI technology to figure out which is the executable.</description>
      <pubDate>Thu, 16 Oct 2008 19:37:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135529#M689022</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-10-16T19:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135530#M689023</link>
      <description>&amp;gt;I suppose you could use shl_get(3) or dlget(3)&lt;BR /&gt;&lt;BR /&gt;Ok, shl_get(3) says use index of -2, unfortunately that only gives the relative path if invoked with one.</description>
      <pubDate>Thu, 16 Oct 2008 23:49:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135530#M689023</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-10-16T23:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135531#M689024</link>
      <description>pst_status pst;&lt;BR /&gt;pst.pst_pid = -1;&lt;BR /&gt;pstat_getproc (&amp;amp;pst, sizeof (pst_status), 0, getpid());&lt;BR /&gt;&lt;BR /&gt;char    pathbuffer[1024];&lt;BR /&gt;pstat_getpathname(pathbuffer,1024,&amp;amp;pst.pst_fid_text);&lt;BR /&gt;printf("Executable full path:%s\n",pathbuffer);&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Nov 2008 09:00:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135531#M689024</guid>
      <dc:creator>yrpark</dc:creator>
      <dc:date>2008-11-14T09:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135532#M689025</link>
      <description>&amp;gt;yrpark: pstat_getpathname(pathbuffer,1024,&amp;amp;pst.pst_fid_text);&lt;BR /&gt;&lt;BR /&gt;Yes, this solution was alluded to in rakeshcs123's other thread:&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1280356" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1280356&lt;/A&gt;</description>
      <pubDate>Fri, 14 Nov 2008 10:58:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135532#M689025</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-11-14T10:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get full path of executable of running process...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135533#M689026</link>
      <description>i solved the problem with some other technique since i could not got the proper solution for this</description>
      <pubDate>Sat, 15 Nov 2008 15:42:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/get-full-path-of-executable-of-running-process/m-p/5135533#M689026</guid>
      <dc:creator>rakeshcs123</dc:creator>
      <dc:date>2008-11-15T15:42:59Z</dc:date>
    </item>
  </channel>
</rss>

