Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 Jun 2009 00:14:51 +0300
From:      Nikos Vassiliadis <nvass9573@gmx.com>
To:        Steven Schlansker <scs@eecs.berkeley.edu>, utisoft@gmail.com,  Kelly Jones <kelly.terry.jones@gmail.com>, freebsd-questions@freebsd.org
Subject:   Re: Waiting for a process to die
Message-ID:  <4A22F34B.1030908@gmx.com>
In-Reply-To: <20090531210357.GA60342@melon.esperance-linux.co.uk>
References:  <26face530905311117te38a4faya92733fbfebd9597@mail.gmail.com>	<b79ecaef0905311128v2e1921a8p30c6ead961759780@mail.gmail.com>	<4A22DDAD.8070504@eecs.berkeley.edu> <20090531210357.GA60342@melon.esperance-linux.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
Frank Shute wrote:
> On Sun, May 31, 2009 at 12:42:37PM -0700, Steven Schlansker wrote:
>> Chris Rees wrote:
>>> [ `ps ax |grep pid | wc -l ` = 1 ] && (echo "done!" | Mail -s "PROC
>>> DONE" kelly.terry.jones@gmail.com)
>>>  
>> Not always going to work.  For example,
>>
>> [steven@scs:~]% ps ax | grep init
>>    1 ?        Ss     0:39 init [2] 
>> 13421 pts/1    R+     0:00 grep init
> 
> This is why you should use pgrep(1) to find a PID (and kill it) rather
> than directly grepping a ps output like the previous poster did.

Yes, pgrep is the tool. If you already know the pid, you can
use good old ps:
ps 1 && echo init runs





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A22F34B.1030908>