Currently, GetApplicationDirectory() works by calling procstat -b <pid> and getting the third field of the line matching the <pid>. The problem is that modern FreeBSD versions return four fields:
So print $3 should really be print $4. Another thing is that filtering the PID line could be avoided if procstat is called with -h (suppress header) switch.
Ideally, however, is not to spawn and chain any processes and read their output with popen(), but ask the system with sysctl() call for the KERN_PROC_PATHNAME as described here.
Currently,
GetApplicationDirectory()
works by callingprocstat -b <pid>
and getting the third field of the line matching the<pid>
. The problem is that modern FreeBSD versions return four fields:So
print $3
should really beprint $4
. Another thing is that filtering the PID line could be avoided ifprocstat
is called with-h
(suppress header) switch.Ideally, however, is not to spawn and chain any processes and read their output with
popen()
, but ask the system withsysctl()
call for theKERN_PROC_PATHNAME
as described here.