<?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: current working directory of process in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093805#M93472</link>
    <description>&lt;!--!*#--&gt;Thanks for the support. we get the current directory from struct pst_status in &lt;SYS&gt; where the field struct __pst_fid pst_fid_cdir;/* Cookie for current working directory */ gives the current working directory for a process.&lt;/SYS&gt;</description>
    <pubDate>Fri, 22 Feb 2008 11:00:05 GMT</pubDate>
    <dc:creator>sanjay khuntia</dc:creator>
    <dc:date>2008-02-22T11:00:05Z</dc:date>
    <item>
      <title>current working directory of process</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093802#M93469</link>
      <description>hi all,&lt;BR /&gt;&lt;BR /&gt;i want to get current working directory for all processes. i am using pstat_ system calls to fetch those information.But the pstat_ calls nowhere return current directory of a process. Can anyone suggest me?&lt;BR /&gt;Regards,&lt;BR /&gt;sanjay</description>
      <pubDate>Thu, 21 Feb 2008 14:49:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093802#M93469</guid>
      <dc:creator>sanjay khuntia</dc:creator>
      <dc:date>2008-02-21T14:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: current working directory of process</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093803#M93470</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;An individual process can use 'getcwd()' to obtain its *own* current working directory [of course].&lt;BR /&gt;&lt;BR /&gt;I don't believe that there is a way (in HP-UX at least) to fetch this information otherwise, though.  For that matter, why would you want to do so?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Feb 2008 15:07:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093803#M93470</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-02-21T15:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: current working directory of process</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093804#M93471</link>
      <description>&lt;!--!*#--&gt;Following code assumes that current working directory&lt;BR /&gt;is found in lookup cache (assumption is in pstat_getpathname). So it may not may not work in all situations..&lt;BR /&gt;&lt;BR /&gt;--vishwas.&lt;BR /&gt;&lt;BR /&gt;-- &lt;BR /&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;FCNTL.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;main(int argc , char **argv)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;        struct pst_status pst[1];&lt;BR /&gt;        int count;&lt;BR /&gt;        char buf[MAXPATHLEN+1];&lt;BR /&gt;        pid_t pid;&lt;BR /&gt;&lt;BR /&gt;        if ( argc != 2 ) {&lt;BR /&gt;                printf("Usage: pwdx &lt;PID&gt;\n");&lt;BR /&gt;                exit(1);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        pid = atol (argv[1]);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;        if ( getppid(pid) &amp;lt; 0 ) {&lt;BR /&gt;&lt;BR /&gt;                fprintf(stderr,"Error: %s %d is not a valid pid.\n",&lt;BR /&gt;                        argv[1],pid);&lt;BR /&gt;                exit(1);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        bzero(buf,MAXPATHLEN+1);&lt;BR /&gt;&lt;BR /&gt;        if ( (count=pstat_getproc(pst, sizeof(pst[0]), 0, pid )) &amp;gt; 0 ) {&lt;BR /&gt;&lt;BR /&gt;                printf("pid is %d, command is %s\n",&lt;BR /&gt;                        pst[0].pst_pid, pst[0].pst_ucomm);&lt;BR /&gt;&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        count = pstat_getpathname(buf,MAXPATHLEN,&amp;amp;pst[0].pst_fid_cdir);&lt;BR /&gt;&lt;BR /&gt;        if (count &amp;gt; 0) {&lt;BR /&gt;                printf("%s\n", buf);&lt;BR /&gt;                exit(0);&lt;BR /&gt;        }&lt;BR /&gt;        else {&lt;BR /&gt;                fprintf(stderr,"ERROR getting the CWD.\n");&lt;BR /&gt;                perror("pstat_getpathname");&lt;BR /&gt;                exit(1);&lt;BR /&gt;        }&lt;BR /&gt;}&lt;/PID&gt;&lt;/STDIO.H&gt;&lt;/FCNTL.H&gt;&lt;/SYS&gt;&lt;/SYS&gt;</description>
      <pubDate>Fri, 22 Feb 2008 02:58:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093804#M93471</guid>
      <dc:creator>Vishwas Pai</dc:creator>
      <dc:date>2008-02-22T02:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: current working directory of process</title>
      <link>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093805#M93472</link>
      <description>&lt;!--!*#--&gt;Thanks for the support. we get the current directory from struct pst_status in &lt;SYS&gt; where the field struct __pst_fid pst_fid_cdir;/* Cookie for current working directory */ gives the current working directory for a process.&lt;/SYS&gt;</description>
      <pubDate>Fri, 22 Feb 2008 11:00:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/current-working-directory-of-process/m-p/5093805#M93472</guid>
      <dc:creator>sanjay khuntia</dc:creator>
      <dc:date>2008-02-22T11:00:05Z</dc:date>
    </item>
  </channel>
</rss>

