Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

source code for linux shell utility pidof

Tags:

linux

shell

Experts,

How do I see the source code for the Linux shell command pidof ? Based on the answers for related questions I checked in the GNU coreutils. It isn't there..

like image 688
Manohar Avatar asked Oct 21 '11 05:10

Manohar


2 Answers

If you are on Debian system like Ubuntu you can try something on these lines: dpkg -S <utility>, this will tell you which package installed this utility; then you can get the source using apt-get source <package-name>. To get the source make sure you have deb-src entry in /etc/apt/sources.list
For example on Ubuntu system I use:

$ dpkg -S pidof
sysvinit-utils: /bin/pidof
sysvinit-utils: /usr/share/man/man8/pidof.8.gz

So the package name is sysvinit-utils

$ apt-get source sysvinit-utils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Picking 'sysvinit' as source package instead of 'sysvinit-utils'
NOTICE: 'sysvinit' packaging is maintained in the 'Svn' version control system at:
svn://svn.debian.org/pkg-sysvinit/sysvinit/trunk
...
dpkg-source: info: extracting sysvinit in sysvinit-2.87dsf
dpkg-source: info: unpacking sysvinit_2.87dsf-4ubuntu17.4.tar.gz

Source package picked. It also inform about svn where the source is maintained.

$ ls sysvinit*
sysvinit_2.87dsf-4ubuntu17.4.dsc  sysvinit_2.87dsf-4ubuntu17.4.tar.gz

sysvinit-2.87dsf:
contrib/  COPYRIGHT  debian/  doc/  man/  obsolete/  README  src/

I am sure there should be equivalent of this on non-Debian systems. Google might help you.
Hope this can help a bit!

Edit: A little info for yum:
1. Search for package: yum whatprovides <package_name> So for pidof maybe:

yum whatprovides `which pidof`

2. Get the source: yumdownloader --source <source_name>. You may need yum-utils for this. More info at this link
Although I have not tried it, but I guess you can give a shot!

like image 61
another.anon.coward Avatar answered Oct 12 '22 05:10

another.anon.coward


I found the pidof source code here: Source Code

like image 37
tr4656 Avatar answered Oct 12 '22 05:10

tr4656