From owner-freebsd-arch@FreeBSD.ORG Wed Dec 22 13:57:36 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A34EF16A4CE for ; Wed, 22 Dec 2004 13:57:36 +0000 (GMT) Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id B7FF643D1D for ; Wed, 22 Dec 2004 13:57:35 +0000 (GMT) (envelope-from jilles@stack.nl) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mailhost.stack.nl (Postfix) with ESMTP id CD8A01F1D0; Wed, 22 Dec 2004 14:57:34 +0100 (CET) Received: by turtle.stack.nl (Postfix, from userid 1677) id BB1B81E230; Wed, 22 Dec 2004 14:57:34 +0100 (CET) Date: Wed, 22 Dec 2004 14:57:34 +0100 From: Jilles Tjoelker To: Kris Kennaway Message-ID: <20041222135734.GA57242@stack.nl> References: <84301.1103663813@critter.freebsd.dk> <41C89672.3000808@freebsd.org> <20041221232354.GA28374@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041221232354.GA28374@xor.obsecurity.org> X-Operating-System: FreeBSD 5.3-RELEASE-p2 i386 User-Agent: Mutt/1.5.6i cc: arch@freebsd.org Subject: Re: Forcefully unmounting devfs... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2004 13:57:36 -0000 On Tue, Dec 21, 2004 at 03:23:54PM -0800, Kris Kennaway wrote: > Unfortunately that's going to cause me a fair amount of pain, unless > there's a simple way to kill all processes running in a given chroot Not that hard, although it is a bit tricky because command names may contain spaces, so something obvious like this does not work in the general case: fstat /chroot |awk '$4 == "root" { print $3 }' But the following seems more reliable, assuming the mount points do not contain spaces: #!/bin/sh # USER CMD PID FD MOUNT INUM MODE SZ|DV R/W NAME # jilles zsh 57711 root / 2 drwxr-xr-x 1024 r / D="$1" fstat "$D" | sed -Ene 's#^.* +([[:digit:]]+) +root +/[^ ]* +[[:digit:]]+ +.......... +[[:digit:]]+ +(r|rw|w) +'"$D"'$#\1#p' This would need some |xargs kill or similar. -- Jilles Tjoelker