Re: Root Directory of a Process

From: Pete Wright <pete_at_nomadlogic.org>
Date: Thu, 29 Jan 2026 20:15:16 UTC

On 1/29/26 07:54, Jishan Alam wrote:
> Hello, I wanted to know how to get the root dir of a process using
> sysctl or other libs, sysctl leads me to kinfo_proc where ki_pd
> contains pwddesc-> pd_pwd which only works in kernel? if not how to
> get it safely is there any way.
> Context: Im porting an app from Linux where the app reads from
> /proc/<pid>/root using readlink but since freebsd doesnt have it, how
> to emulated if it can be emulated.

i think libprocstat(3) would be the way to go here.  i use procstat(1) 
for shell scripting to get surface info similar to linux's procfs, so 
that might have what you are looking for.

-pete

-- 
Pete Wright
pete@nomadlogic.org