3 ms·
Minor nitpick: calling it a a clone of the Unix 'ps' wouldn't be exactly right, since I understand /proc is Linux-specific. On the other hand, how did the Unix
by gshrikant 10y ago
Minor nitpick: calling it a a clone of the Unix 'ps' wouldn't be exactly right, since I understand /proc is Linux-specific. On the other hand, how did the Unix 'ps' or the 'ps' in other Unix-clones work? Is there an alternative method to expose the process data to userspace instead of using a VFS like procfs?
- binarycrusader 10y ago/proc is not Linux-specific; my late, great Colleague Roger Faulkner did a lot of work on it in Solaris: https://www.usenix.org/memoriam-roger-faulkner https://www.usenix.org/memoriam-roger-faulkner ...and there's a general history here: https://blogs.oracle.com/eschrock/entry/the_power_of_proc https://blogs.oracle.com/eschrock/entry/the_power_of_proc The part that may be specific to Linux is Linux provides a text-based interface, whereas systems like Solaris provide a binary interface.
- gshrikant 10y agoThat link is really interesting! Thanks for that. I should have probably said procfs is Linux-specific. Anyway, learned (rather unlearned) something new today. Also interesting is that early Unix systems (before v8) used `ptrace()` for gathering process information - the same system call programs like strace/ltrace use today.
- binarycrusader 10y agoNo, procfs is also not Linux specific ;-) /proc is a filesystem, so most of us refer to it as 'procfs' for short. In fact, the header file you include a C program in Solaris to use it is '<procfs.h>'. As I said before, the only thing that's really Linux-specific is Linux chose to represent it as text instead of something machine-parsable.
- pietromenna 10y agoWhich other OS uses procfs?
- konstmonst 10y agoHier is the history https://en.wikipedia.org/wiki/Procfs https://en.wikipedia.org/wiki/Procfs I think the one from linux was inspire by plan9's implementation.
- pietromenna 10y agoThank you!
- geofft 10y agoThere are a couple of options. A good number of other UNIXes do in fact have a procfs. Some others, like macOS, have a system call that gives you the information you want (on macOS this is a sysctl, CTL_KERN / KERN_PROC / KERN_PROC_ALL, which returns a set of structs). And finally, especially on older UNIXes, the ps command is setuid root, and goes and opens /dev/kmem or similar and looks around in kernel memory and parses the live kernel's process table directly.
- digi_owl 10y agoYou may be thinking of sysfs.