X-Spam-Check-By: sourceware.org Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Subject: RE: Possible bug in pgrep (procps) Date: Mon, 17 Jul 2006 16:07:36 -0700 Message-ID: <1BBF464ECC68FB4AA7EF4AB997CC07310142A63C@NA-PA-VBE01.na.tibco.com> From: "Matthew Woehlke" To: "Bengt-Arne Fjellner" , Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k6HN7uRs004551 (http://cygwin.com/acronyms/#PPIOSPE) mwoehlke skrev: > Bengt-Arne Fjellner wrote: >> pgrep from procps-3.2.6-1 when asking for an exact match with >> arguments seems to demand an extra space after the argument. >> See the following sequence. >> >> No space after the f on the commandline $ emacs f& [1] 2072 >> >> without extra space >> $ pgrep -x -f "emacs f" >> >> with extra space after f >> $ pgrep -x -f "emacs f " >> 2072 >> >> Bug or my misunderstanding ? > > Sure sounds like a bug, unless 'grep "foo"' is no longer supposed to > match the line "foo "... 'man pgrep' isn't very specific on how the > pattern matching is supposed to work, so I would assume partial > matches are expected to work (as they would in grep). > > Interestingly enough, on my computer (cygwin 1-5-19.4, procps > 3.2.6-1), I see the following: > > $ sleep 1h& > [1] 2136 > $ pgrep -f 'sleep 1h' > 2136 > $ pgrep -f 'sleep 1h ' > 2136 > $ pgrep -f 'sleep 1h ' > $ > > This also seems wrong; 'sleep 1h ' should not have matched anything IMO. > It does seem like there is something fishy going on. Well I have now confirmed it. The code that builds the full commandline adds "the n:th arg" and a space to a buffer then loops around until all args are used up. It should kill the last space. and to restrict matches you have to add a -x for exact match. so your command is (for pgrep) 'sleep 1h ' and 'sleep 1h' should match but 'sleep 1h ' shouldnt. and when asking for exact match only 'sleep 1h ' fits P.S. I think never versions on linux might have this bug to. > > -- > Matthew > Interix, Sphinterix. Cygwin apps don't crash. :-) > -- Bengt-Arne Fjellner -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/