Where to find the source code for ps?
9,828
Solution 1
Ps belongs to procps-ng
, git repository is here
To fetch it,
git clone https://gitlab.com/procps-ng/procps.git
Solution 2
Check procps or procps-ng (the latter is used by Debian/Fedora/openSUSE/Arch and other distros).
procps is the package that has a bunch of small useful utilities that give information about processes using the /proc filesystem. The package includes the programs ps, top, vmstat, w, kill, free, slabtop, and skill.
which looks unmaintained and was forked into procps-ng
Debian, Fedora and openSUSE fork of procps. For more information about the former upstream see http://procps.sourceforge.net.
Related videos on Youtube
Author by
TheLegassis
Updated on September 18, 2022Comments
-
TheLegassis over 1 year
I want to check out the source code for commands such as ps. It seems to be impossible to search LXR (linux.no) for "ps". Where do I find it?
-
TheLegassis over 11 yearsRenan, I understand.. but where would I find this in Linux source tree?
-
TheLegassis over 11 yearsSure, but where is it in the source tree?
-
daisy over 11 years@TheLegassis it's a userland tool, what you looking for?
-
TheLegassis over 11 yearsHi warl0ck, so I am interested in how it gets included in every Linux build I used. Is it precompiled? I would like to take a look at the source code and modify it
-
Renan over 11 years@TheLegassis it is not in the Linux source tree (it's userland, not kernel stuff). To get the source code go to the links I gave.
-
TheLegassis over 11 yearsAlright, how does ps get the process information? Through /proc directory or does it use a system call?
-
cheshirecatalyst over 11 yearsFor that type of question, it would be best to just look at the source.
-
Kotte over 11 yearsIf you want to know how programs obtain information about the system you can use
strace
. -
daisy over 11 years@TheLegassis yes, procps reads from /proc, proc-ps
-
bdsl over 8 years@TheLegassis I think the answer to your question about how ps gets included in Linux distributions (not really builds as such) is simply that the people distribution operating systems based on Linux, such as Red Hat, Debian, Ubuntu etc have chosen to include it. They give you a copy of ps alongside the Linux kernel and lots of other software.
-
Fatih Köse over 4 yearsI think gitorious.org/procps/procps.git is outdated. Probably it has been moved to gitlab.com/procps-ng/procps/-/wikis/home, but I can't find a reliable source which proves that this is the right one. Here is the old link too fedoraproject.org/wiki/Features/procps-ng.
-
JamesTheAwesomeDude about 2 years@TheLegassis To actually answer your question: the current version of the code reads files out of the
/proc
directory; a cursory look at thegit blame
suggests it's done this since forever.