From owner-freebsd-questions@FreeBSD.ORG Sun May 31 21:15:56 2009 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 5C2B0106566C for ; Sun, 31 May 2009 21:15:56 +0000 (UTC) (envelope-from nvass9573@gmx.com) Received: from mail.gmx.com (unknown [213.165.64.42]) by mx1.freebsd.org (Postfix) with SMTP id A2D3B8FC1E for ; Sun, 31 May 2009 21:15:55 +0000 (UTC) (envelope-from nvass9573@gmx.com) Received: (qmail invoked by alias); 31 May 2009 21:15:54 -0000 Received: from ipa175.88.107.79.tellas.gr (EHLO [192.168.254.1]) [79.107.88.175] by mail.gmx.com (mp-eu003) with SMTP; 31 May 2009 23:15:54 +0200 X-Authenticated: #46156728 X-Provags-ID: V01U2FsdGVkX1/1GhBdcbD1phHAW7TvOFzD4jbLJJ7KT7s3zvRLja Xqy996AINcICq5 Message-ID: <4A22F34B.1030908@gmx.com> Date: Mon, 01 Jun 2009 00:14:51 +0300 From: Nikos Vassiliadis User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Steven Schlansker , utisoft@gmail.com, Kelly Jones , freebsd-questions@freebsd.org References: <26face530905311117te38a4faya92733fbfebd9597@mail.gmail.com> <4A22DDAD.8070504@eecs.berkeley.edu> <20090531210357.GA60342@melon.esperance-linux.co.uk> In-Reply-To: <20090531210357.GA60342@melon.esperance-linux.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.58 Cc: Subject: Re: Waiting for a process to die 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: Sun, 31 May 2009 21:15:56 -0000 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