From owner-freebsd-questions@FreeBSD.ORG Thu Jun 10 07:45:48 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15B3F106567C for ; Thu, 10 Jun 2010 07:45:48 +0000 (UTC) (envelope-from j.mckeown@ru.ac.za) Received: from d.mail.ru.ac.za (d.mail.ru.ac.za [IPv6:2001:4200:1010::25:4]) by mx1.freebsd.org (Postfix) with ESMTP id 18C878FC25 for ; Thu, 10 Jun 2010 07:45:47 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=ru-msa; d=ru.ac.za; h=Received:From:Organization:To:Subject:Date:User-Agent:References:In-Reply-To:X-Face:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-Disposition:Message-Id:X-Virus-Scanned:X-Authenticated-User; b=naeLwYxml1LmrnFGPqYzriVKNLBi/G1j92qCQlfA8T4mIsr1E3LTyrkba8miqcnF15sxVr7lfMJjkZSBz+nrLVzZN6RhhJfDjYZVJ3j8xW2x7manDe23X/s0cg6TJHH8; Received: from vorkosigan.ru.ac.za ([2001:4200:1010:1058:219:d1ff:fe9f:a932]:52945) by d.mail.ru.ac.za with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69 (FreeBSD)) (envelope-from ) id 1OMcSO-000ONL-CR for freebsd-questions@freebsd.org; Thu, 10 Jun 2010 09:45:44 +0200 From: Jonathan McKeown Organization: Rhodes University To: freebsd-questions@freebsd.org Date: Thu, 10 Jun 2010 09:45:44 +0200 User-Agent: KMail/1.9.10 References: <4C0F4410.40900@infracaninophile.co.uk> <201006100330.14618.pieter@degoeje.nl> In-Reply-To: <201006100330.14618.pieter@degoeje.nl> X-Face: $@VrUx^RHy/}yu]jKf/<4T%/d|F+$j-Ol2"2J$q+%OK1]&/G_S9(=?utf-8?q?HkaQ*=60!=3FYOK=3FY!=27M=60C=0A=09aP=5C9nVPF8Q=7DCilHH8l=3B=7E!4?= =?utf-8?q?2HK6=273lg4J=7Daz?=@1Dqqh:J]M^"YPn*2IWrZON$1+G?oX3@ =?utf-8?q?k=230=0A=0954XDRg=3DYn=5FF-etwot4U=24b?=dTS{i X-Virus-Scanned: d.mail.ru.ac.za (2001:4200:1010::25:4) X-Authenticated-User: s0900137 from vorkosigan.ru.ac.za (2001:4200:1010:1058:219:d1ff:fe9f:a932) using auth_plaintext Subject: Re: why does ps |grep sometimes not return itself? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2010 07:45:48 -0000 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