7 ms·
`readlink -e /proc/$$/exe` would be a simple solution on linux -> /proc is such a fun treasure trove of process info :-) (Not sure it macOS has as much info in
by bruce_one 6y ago
`readlink -e /proc/$$/exe` would be a simple solution on linux -> /proc is such a fun treasure trove of process info :-)
(Not sure it macOS has as much info in /proc?)
- codetrotter 6y ago> Not sure it macOS has as much info in /proc? macOS does not have procfs
- msla 6y ago> macOS does not have procfs https://en.wikipedia.org/wiki/Procfs https://en.wikipedia.org/wiki/Procfs It also got dropped from OpenBSD: > It was removed from OpenBSD in version 5.7, which was released in May 2015, because it "always suffered from race conditions and is now unused".[2] The OpenBSD people don't say what you should replace it with, but backing up in the paragraph, the FreeBSD people do: > As of February 2011, procfs is gradually becoming phased out in FreeBSD.[1] Chasing that reference: https://lists.freebsd.org/pipermail/freebsd-fs/2011-February/010760.html https://lists.freebsd.org/pipermail/freebsd-fs/2011-February... > Why is procfs deprecated in favor of procstat? [snip] > The security issues are long-standing and there have been many over the years, but the real reason is something that's less evident (or at least less directly apparent): > Simply put, procfs on FreeBSD has been neglected. There isn't a lot of attention being given to it, and the only modifications in recent months/years have been generally minor compared to the rest of the tree. You can review some of the commits yourself: > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/fs/procfs/ http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/fs/procfs/ > Others like yourself have asked what the state of procfs is, going back as far as 2005. Be sure to read the reply as well: > http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-05/2607.html http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/20... Here's the FreeBSD procstat manpage: https://www.freebsd.org/cgi/man.cgi?procstat https://www.freebsd.org/cgi/man.cgi?procstat Aside from bitrot, is there a reason to prefer procstat over procfs?
- core_dumped 6y agoDo you have any resources about /proc you'd recommend?
- nick0garvey 6y ago`man proc' is quite good. https://man7.org/linux/man-pages/man5/proc.5.html https://man7.org/linux/man-pages/man5/proc.5.html /proc is Linux specific, but it's extremely useful. A lot of tools are actually built on top of it, for example ps. ngarvey@cheapo:~$ strace ps aux |& grep cmdline | head openat(AT_FDCWD, "/proc/1/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/2/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/3/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/4/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/9/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/10/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/11/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/12/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/13/cmdline", O_RDONLY) = 6 openat(AT_FDCWD, "/proc/14/cmdline", O_RDONLY) = 6
- pjmlp 6y agoActually it was copied from Solaris, https://docs.oracle.com/cd/E19253-01/816-5174/proc-4/index.html https://docs.oracle.com/cd/E19253-01/816-5174/proc-4/index.h...
- simlevesque 6y agodoes not work in Fish Shell. fish: $$ is not the pid. In fish, please use $fish_pid. readlink -e /proc/$$/exe ^