Hello,
i think, this simple hack will do the job:
#!/usr/bin/bash
echo Following programs are using /proc
for i in /usr/bin/* /usr/sbin/*
do
if [[ ! -x "$i" ]]; then continue; fi
ldd "$i" 2>/dev/null | grep -F libproc2 &>/dev/null
if [[ $? == 0 ]]
then
echo $i
fi
done
Best regards
Andreas
Sorry, when I execute this, I get zero/nada/nothing output!!!
Hmm, I have no clue:
andi@adler:~$ vim bin/bla.sh # i do copy paste of the code
andi@adler:~$ bash bin/bla.sh
Following programs are using /proc
/usr/bin/free
/usr/bin/pgrep
/usr/bin/pidof
/usr/bin/pidwait
/usr/bin/pkill
/usr/bin/pmap
/usr/bin/ps
/usr/bin/skill
/usr/bin/slabtop
/usr/bin/snice
/usr/bin/tload
/usr/bin/top
/usr/bin/uptime
/usr/bin/vmstat
/usr/bin/w
/usr/sbin/pidof
andi@adler:~$ cat /etc/redhat-release
Fedora release 40 (Forty)
For debugging you can try:
ldd /usr/bin/uptime
ldd /usr/bin/uptime | grep -F libproc2
Best regards
Andreas
Found the problem
The problem is the name of the shared lib.
Better to grep for libproc instead libproc2
Fedora uses libproc2.
Red Hat uses libprocps.
Corrected script:
#!/usr/bin/bash
echo Following programs are using /proc
for i in /usr/bin/* /usr/sbin/*
do
if [[ ! -x "$i" ]]; then continue; fi
ldd "$i" 2>/dev/null | grep -F libproc &>/dev/null
if [[ $? == 0 ]]
then
echo $i
fi
done
Best regards
Andreas
Additional info:
lsof is not part of my result. The problem is, that `lsof` does not use libproc....
The command "strace lsof dummy_one" shows that lsof is using /proc. Also the command strings /usr/bin/lsof shows up /proc.
Both commands were my first idea for my shell script. But I have no idea how I can start all different programs correctly ;-).
Edit: sysctl do not use libproc... too. Found with the command: MANSECT="1,8" man -wiK procfs
I hope you don't get upset with me, but I knew where the error
was when I posted my comment!!!
I'm big on troubleshooting, because I know it ALWAYS presents
an opportunity to learn. I didn't want to take away that opportunity
from you by telling you where the issue was.
I wanted you to put your finger on the issue, which I felt should
have been very easy to do - if this was in fact your work!!! Okiay,
don't get defensive - I'm not questioning if this was your work!!
If know you that you're the author, then the problem will lie with
any doubters, not you!!!
If this was your work, you can feel good about the composition.
It definitely gets the job done - spit out the names of all commands
that use the /proc filesystem. Considering all the executables that
exist on a Linux system, your script gives support to automate things!
Anyway, hope that you won't curse me, but instead take my intentions
in the spirit that they were intended!
In closing, great job!!!!
You received that very well. Thank you!!!
And thank you again for your contribution to my initial query!!!
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.