Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Jan 1999 23:29:46 -0600
From:      Dan Nelson <dnelson@emsphone.com>
To:        Eugeny Kuzakov <kev@lab321.ru>
Cc:        questions@FreeBSD.ORG
Subject:   Re: pid&work dir
Message-ID:  <19990124232946.A14190@dan.emsphone.com>
In-Reply-To: <Pine.BSF.4.02.9901251121500.15040-100000@lab321.ru>; from "Eugeny Kuzakov" on Mon Jan 25 11:25:39 GMT 1999
References:  <19990124231635.A13953@dan.emsphone.com> <Pine.BSF.4.02.9901251121500.15040-100000@lab321.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Jan 25), Eugeny Kuzakov said:
> On Sun, 24 Jan 1999, Dan Nelson wrote:
> > > One question.
> > > I know PID of process. How can I know work dir, where it run ?
> > > Linux has key for ps. In Solaris I can view it in /proc..
> > > thaks for advices.
> > fstat -p pid
> > or (after installing /usr/ports/sysutils/lsof)
> > lsof -p pid
> > I recommend using lsof, since it's portable across most Unixes and that
> > means you only have to learn one command.
> I know about this. This commands shows which files/sockets process
> use... "I know work dir, where it run ?"...

$ pwd
/usr/home/dan
$ echo $$
2593
$ lsof -p 2593
COMMAND  PID USER   FD   TYPE   DEVICE SIZE/OFF   NODE NAME
sh      2593  dan  cwd   VDIR 4,196608     2048 192017 /usr/home/dan
sh      2593  dan  rtd   VDIR 4,196608     1024      2 /
sh      2593  dan  txt   VREG 4,196608   355088 131945 /bin/sh
sh      2593  dan    0u  VCHR     12,2   0t3605  13266 /dev/ttyv2
sh      2593  dan    1u  VCHR     12,2   0t3605  13266 /dev/ttyv2
sh      2593  dan    2u  VCHR     12,2   0t3605  13266 /dev/ttyv2
$

The filedescriptor marked "cwd" is the current working directory.

	-Dan

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990124232946.A14190>