Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jun 2010 09:45:44 +0200
From:      Jonathan McKeown <j.mckeown@ru.ac.za>
To:        freebsd-questions@freebsd.org
Subject:   Re: why does ps |grep sometimes not return itself?
Message-ID:  <201006100945.44151.j.mckeown@ru.ac.za>
In-Reply-To: <201006100330.14618.pieter@degoeje.nl>
References:  <AANLkTimdtot-1vlYofXo-dv3V7jyFW7VU0D6dq3vqBqV@mail.gmail.com> <4C0F4410.40900@infracaninophile.co.uk> <201006100330.14618.pieter@degoeje.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 10 June 2010 03:30:14 Pieter de Goeje wrote:
> On Wednesday 09 June 2010 09:34:40 Matthew Seaman wrote:
> > On 09/06/2010 08:15:23, Eitan Adler wrote:
> > > Why do I sometimes see the grep in ps's output and sometimes not see
> > > it?
> >
> > When you run that pipeline the OS doesn't start both programs exactly
> > simultaneously. [...]  It's a race condition.
>
> I would like to add that you can avoid the issue entirely by using this
> command:
> % ps aux -p `pgrep sh`
[output snipped due to bad wrapping]

Or the old trick:

ps | grep '[s]h'

Jonathan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006100945.44151.j.mckeown>