From owner-freebsd-arch@FreeBSD.ORG Mon Aug 5 11:13:15 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 58A499C2 for ; Mon, 5 Aug 2013 11:13:15 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-ea0-x232.google.com (mail-ea0-x232.google.com [IPv6:2a00:1450:4013:c01::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DE31F2785 for ; Mon, 5 Aug 2013 11:13:14 +0000 (UTC) Received: by mail-ea0-f178.google.com with SMTP id a15so1572073eae.9 for ; Mon, 05 Aug 2013 04:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=aPWBKWhEpyzrKXEQqoZOV1K91Cw72HDaYY/XqsaB1y8=; b=0UGiz4Vp906tbY9lHtu/zTL2TdNZ+o9EzwawhdwIwfu9x1eODH2sYqgb3SJGMbyYrM xFICP84gDAS5NrdPlnb8G3DQW7Di694VcIQ+h38o6MyywEn9+AYjsBmyXVuDBxOPVJA9 tUj67qrJi7vzLQVSGmqBSsVX3OCl/9CI444btfsqMoOXgm2ltk6CRU5+d/ne0cGmIZ3D qD3m7PmVEXUT7tZWYMUJd8UgVTyktxycsWsP8XNS3/vkz2/FAM0AklftffGDlI2QCLXc y2ubYAfe/8ya4dFBhj+MOaQ8nyXuD4myHN+oXwegmMFT5eHM2PG9fadHf+F2Pkhv3FCP SQKA== X-Received: by 10.14.184.4 with SMTP id r4mr16532290eem.100.1375701193127; Mon, 05 Aug 2013 04:13:13 -0700 (PDT) Received: from [192.168.1.4] (aac168.neoplus.adsl.tpnet.pl. [83.25.2.168]) by mx.google.com with ESMTPSA id cg12sm32535522eeb.7.2013.08.05.04.13.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 Aug 2013 04:13:12 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Content-Type: text/plain; charset=iso-8859-2 Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: Reliable process tracking From: =?iso-8859-2?Q?Edward_Tomasz_Napiera=B3a?= In-Reply-To: <20130804134658.GC35080@stack.nl> Date: Mon, 5 Aug 2013 13:13:10 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20130804134658.GC35080@stack.nl> To: Jilles Tjoelker X-Mailer: Apple Mail (2.1508) Cc: freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2013 11:13:15 -0000 Wiadomo=B6=E6 napisana przez Jilles Tjoelker w dniu 4 = sie 2013, o godz. 15:46: > When shutting down a service or requesting status, rc.subr currently > uses a combination of pidfiles and process names. This is fairly but = not > completely reliable once it is set up correctly (which can take a lot = of > work and possibly patching the daemon to use pidfile(3) from our > libutil). It is also incapable of killing multiprocess daemons such as > CGI web servers without cooperation of the daemon. >=20 > I think what is needed here is a facility that marks a process and all > of its descendants. Removing the mark should be a privileged or at = least > an unusual operation; no unprivileged function specified by POSIX such > as setsid() should do this. I've actually thought about that when I added setloginclass(2). It's = trivial to modify rc.subr to use su(8) to set login class for each service. It = should be trivial to modify pkill(1) and killall(1) to add "-c" option to kill = all processes in a given login class. Two caveats: 1. Login classes, just like UIDs, are global, not per jail. This means = when you want to kill all processees in a login class, you should probably = use "-j" option to limit it to a given jail, e.g. jail 0. 2. I'm not sure if pkill(1) has any special way of handling this, but = there is an obvious race condition between iterating over processes in = userland in pkill(1) and quickly forking processes to kill. Perhaps we should = have some kind of syscall to do it in a race-free way?