From mboxrd@z Thu Jan 1 00:00:00 1970 From: Derek Fawcus To: 9fans@cse.psu.edu Subject: Re: [9fans] plan 9 ports to unix (including libdraw) Message-ID: <20031017213548.H23130@edinburgh.cisco.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: ; from cjones83@csc.com on Fri, Oct 17, 2003 at 02:21:22PM -0400 Date: Fri, 17 Oct 2003 21:35:48 +0100 Topicbox-Message-UUID: 718a10ce-eacc-11e9-9e20-41e7f4b1d025 On Fri, Oct 17, 2003 at 02:21:22PM -0400, Caerwyn B Jones wrote: > > The tricky bit is to get the current working directory of the shell. > On Solaris it's possible to use /proc/n/cwd to find it out. There's > probably an equivalent on Linux. Well from the below, it's similar. I believe that readlink() on /proc/n/cwd (for linux) will get what you want. I'm not sure what one does on solaris. DF Solaris: $ ls -l /proc/$$ total 2717 -rw------- 1 dfawcus 2752512 Oct 16 19:09 as -r-------- 1 dfawcus 152 Oct 16 19:09 auxv -r-------- 1 dfawcus 36 Oct 16 19:09 cred --w------- 1 dfawcus 0 Oct 16 19:09 ctl lr-x------ 1 dfawcus 0 Oct 16 19:09 cwd -> dr-x------ 2 dfawcus 8208 Oct 16 19:09 fd -r--r--r-- 1 dfawcus 120 Oct 16 19:09 lpsinfo -r-------- 1 dfawcus 912 Oct 16 19:09 lstatus -r--r--r-- 1 dfawcus 536 Oct 16 19:09 lusage dr-xr-xr-x 3 dfawcus 48 Oct 16 19:09 lwp -r-------- 1 dfawcus 2304 Oct 16 19:09 map dr-x------ 2 dfawcus 544 Oct 16 19:09 object -r-------- 1 dfawcus 2776 Oct 16 19:09 pagedata -r--r--r-- 1 dfawcus 336 Oct 16 19:09 psinfo -r-------- 1 dfawcus 2304 Oct 16 19:09 rmap lr-x------ 1 dfawcus 0 Oct 16 19:09 root -> -r-------- 1 dfawcus 1440 Oct 16 19:09 sigact -r-------- 1 dfawcus 1232 Oct 16 19:09 status -r--r--r-- 1 dfawcus 256 Oct 16 19:09 usage -r-------- 1 dfawcus 0 Oct 16 19:09 watch -r-------- 1 dfawcus 3648 Oct 16 19:09 xmap Linux: ; ls -l /proc/$pid total 0 -r--r--r-- 1 dfawcus dfawcus 0 Oct 17 21:28 cmdline lrwxrwxrwx 1 dfawcus dfawcus 0 Oct 17 21:28 cwd -> /home/dfawcus -r-------- 1 dfawcus dfawcus 0 Oct 17 21:28 environ lrwxrwxrwx 1 dfawcus dfawcus 0 Oct 17 21:28 exe -> /usr/packages/rc-1.6b3/bin/rc-el dr-x------ 2 dfawcus dfawcus 0 Oct 17 21:28 fd -r--r--r-- 1 dfawcus dfawcus 0 Oct 17 21:28 maps -rw------- 1 dfawcus dfawcus 0 Oct 17 21:28 mem lrwxrwxrwx 1 dfawcus dfawcus 0 Oct 17 21:28 root -> / -r--r--r-- 1 dfawcus dfawcus 0 Oct 17 21:28 stat -r--r--r-- 1 dfawcus dfawcus 0 Oct 17 21:28 statm -r--r--r-- 1 dfawcus dfawcus 0 Oct 17 21:28 status