Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Unknown Newsgroups: comp.os.linux.misc,alt.os.linux.debian,alt.os.linux.slackware Subject: Re: mc finds more than `find` finds? Date: Sun, 3 Jan 2016 12:52:01 -0000 (UTC) Organization: A noiseless patient Spider Lines: 95 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 3 Jan 2016 12:52:01 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="f37704ebdfc47f45962749fd3d1297cb"; logging-data="2426"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EGtrdOel4P7/hgxrDObsweaEFUtIs74Q=" User-Agent: Pan/0.133 (House of Butterflies) Cancel-Lock: sha1:HhYu7g29y5t2Qf3x9NimQGt2nYM= Xref: csiph.com comp.os.linux.misc:16658 alt.os.linux.debian:7672 alt.os.linux.slackware:26053 On Mon, 30 Nov 2015 15:59:09 +0000, Joe Beanfish wrote: > On Sat, 28 Nov 2015 00:37:49 +0000, WhoCares wrote: > >> I'm still searching for a way to know the pid of eg. the instance of >> `wily` which is has a certain file open. >> >> `pgrep wily` lists all the instances of 'wily' >> >> I was hoping that, I'd find which wily has opened file *CONTROL* by:- >> for PID in `pgrep wily`; do find /proc/$PID -exec grep -l "CONTROL" {} >> \; >> trace; done --- that's supposed to be ONE line --- >> >> Using successive refinement: >> first I used mc to browse /proc/24357 to find a suitable search >> target. >> Obviously "wily" would be there. >> >> Then I 'confirmed ?': >> find /proc/24357 -exec grep "wily" {} \; >> but that failed, although mc could find several "wily" in /proc/24357 >> >> OK, we know that /proc is some kind of spooky FS ? So, I copied to >> /find, [using mc] 2 of the files of /proc/24357 which contain "wily", >> and of course, they are found by: >> find /find -exec grep "wily" {} \; == >> ./status >> ./environ >> >> How can mc look into /proc/24357 and show the contents if the basic >> `find` can't see it? > > Are you looking for file names or file content? Find looks at names then > your exec'd grep will look at content in the found files. If you want to > search by file names do > > for PID in `pgrep wily`; do find /proc/$PID -name "CONTROL" -print >> > trace; done > > or > > for PID in `pgrep wily`; do find /proc/$PID -print|grep "CONTROL" >> > trace; done ------------ I'm wondering how/why I failed to explain what's required - because it's unusual? Let's not waste effort, by partially completed journeys.... So I opened a wily on dir: /mnt/h15/var/CONTROL/ BTW I'm writing/testing this in wily now. Like its example-that-plan9-copied: ETHO; For your 2 examples, "trace" is created -- but is empty. -> HasOpenPath2: lsof | grep wily | grep CONTROL |awk '{print $1 " : " $2 " : " $9 }' == wily : 4272 : /mnt/h15/var/CONTROL -> find /proc/4272 -exec grep "CONTROL" {} \; == nX: !?!? but when I open `mc` in /proc/4272 , and string "CONTROL", I find: /proc/4272/environ => File: environ Line 1 Col 3121 3587 bytes ==... h15/usr/local/bin/wily.LC_COLLATE=C.PWD=/mnt/h15/var/CONTROL.INPUTRC=/etc/ input -- So as seems reasonable: pid:4272 has PWD=/mnt/h15/var/CONTROL in its env But HOW to print-out from 'dotty files'? --------- I've just had a partial CRASH, and have lost details. BTW, I'm wrong. This doesn't lead to the solution of: which WorkSpace has the mc, which is currently open [with either of its 2 panels] on . Consider the problem: you've got 20 WS/Desktops open, with `pgrep mc| wc -l` == 22 and some info arrives for which you believe is ALREADY in some mc; but you need to know WHICH WS to open to get *that* mc. Scrolling blackbox's WS-menu shows you which WS has a LIVE [one of 2] panel on . Advanced/smart-arse WMs show nothing. Where the mc was launched from [apparently in the env] is of no interest, which is what my above test show. BTW-BTW !! wily showed a for find /proc/4272 -exec grep "CONTROL" {} \; Messing with /proc/* is not advised? Now I've copied /proc//environ where I can investigate how to grep it: -> grep CONTROL /root/.pan2/article-cache/environ == Binary file /root/.pan2/article-cache/environ matches But as stated: mc let's you look inside .