From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/2135 Path: news.gmane.org!not-for-mail From: Wayne Marshall Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: What is the process group hack Date: Thu, 26 Apr 2012 20:27:53 +0200 Organization: b0llix.net: un!x for the deranged Message-ID: <20120426202753.1cc24411@b0llix.net> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1335464931 26568 80.91.229.3 (26 Apr 2012 18:28:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 26 Apr 2012 18:28:51 +0000 (UTC) Cc: supervision@list.skarnet.org To: harish badrinath Original-X-From: supervision-return-2369-gcsg-supervision=m.gmane.org@list.skarnet.org Thu Apr 26 20:28:49 2012 Return-path: Envelope-to: gcsg-supervision@plane.gmane.org Original-Received: from antah.skarnet.org ([212.85.147.14]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1SNTQo-0006T8-Qi for gcsg-supervision@plane.gmane.org; Thu, 26 Apr 2012 20:28:42 +0200 Original-Received: (qmail 766 invoked by uid 76); 26 Apr 2012 18:32:28 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 756 invoked from network); 26 Apr 2012 18:32:27 -0000 In-Reply-To: X-Mailer: Claws Mail 3.7.7 (GTK+ 2.22.1; x86_64--netbsd) Xref: news.gmane.org gmane.comp.sysutils.supervision.general:2135 Archived-At: On Thu, 26 Apr 2012 20:45:28 +0530 harish badrinath wrote: > Hello, > > I Could not figure out what "process group hack" is supposed > to be utilized for ?? > Is it used to supervise daemons that stubbornly fork into the > background. Could anyone please explain with an example, i > would be really helpful. I have to the best of my abilities > RTFM'ed and searched the internet. > > Thank you, > Harish > This question refers to specific utilities in the daemontools suite by Daniel Bernstein. pgrphack is simply a wrapper around the setsid(2) system call. It runs a process in a new session and process group. See the man page for setsid(2) for more information. See also the source file pgrphack.c in the daemontools distribution. fghack is djb's "anti-backgrounding" utility. It invokes strangeness and mysteries to inhibit a process from forking into the background. Dunno about examples. Normally it is not used because: 1) nowadays most programs that daemonize will be decently written and offer an option to run in the foreground; or -- if such option is not provided -- 2) it is usually a simple matter to delete a few lines of the offensive source code to cut out the daemonizing behavior. It should be mentioned that daemontools itself should be considered deprecated by several alternatives currently available and under active maintenance. For example, runit, daemontools-encore, and perp. I believe most of these tools now run each service in its own session and process group as a matter of course, something that daemontools does not do, unless you yourself explicitly run each service under the pgrphack utility. Why does this matter? If the entire supervision tree runs under a single process group, that entire process tree can be crashed under certain conditions in some cases on some platforms. Which is a bad thing. Internally segregating each service into its own process group is more reliable, and generally eliminates any need for something like pgrphack within the service definitions themselves. Wayne http://b0llix.net/perp/