From owner-freebsd-arch@FreeBSD.ORG Mon Dec 1 18:52:44 2014 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 839CC52A for ; Mon, 1 Dec 2014 18:52:44 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EDAA0863 for ; Mon, 1 Dec 2014 18:52:43 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id sB1IqcU8014504 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 1 Dec 2014 20:52:38 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua sB1IqcU8014504 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id sB1IqckZ014503 for arch@freebsd.org; Mon, 1 Dec 2014 20:52:38 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 1 Dec 2014 20:52:37 +0200 From: Konstantin Belousov To: arch@freebsd.org Subject: Process reapers Message-ID: <20141201185237.GC97072@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2014 18:52:44 -0000 Please find at https://www.kib.kiev.ua/kib/reaper.6.patch the patch which adds a way for the process to declare itself a reaper for the subtree of processes forked after the event. In other words, after the process is marked as reaper, all orphaned children somewhere in subtree after the reaper, are reparented to the process instead of init(8). The API is based on the following DragonFlyBSD commit http://gitweb.dragonflybsd.org/dragonfly.git/commit/fc3bc2868ad212f3b412ad13f0eaa35b3f8d458d Linux has somewhat similar prctl(PR_SET_CHILD_SUBREAPER). Solaris is most advanced in the area, the feature which provides the same function is contracts(4), which is very advanced and IMO over-designed interface. I did not wrote the man page, the API is still in flux. It should be relatively clean how to use the thing by the descriptive names and comments in header file. One of the test programs illustrating the interface is available at https://www.kib.kiev.ua/kib/reaper2.c . See http://leaf.dragonflybsd.org/cgi/web-man?command=procctl§ion=2 for the description of DragonFly interface. The feature was requested by bapt, jilles already provided useful feedback that was incorporated into the patch. Please review and comment.