supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Wayne Marshall <wcm@b0llix.net>
To: harish badrinath <harishbadrinath@gmail.com>
Cc: supervision@list.skarnet.org
Subject: Re: What is the process group hack
Date: Thu, 26 Apr 2012 20:27:53 +0200	[thread overview]
Message-ID: <20120426202753.1cc24411@b0llix.net> (raw)
In-Reply-To: <CAFUoqbfjBoBAu3h-+CvD9CXvV3YEEbPgzSyL1qHKreitLi870A@mail.gmail.com>

On Thu, 26 Apr 2012 20:45:28 +0530
harish badrinath <harishbadrinath@gmail.com> 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/


  parent reply	other threads:[~2012-04-26 18:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 15:15 harish badrinath
2012-04-26 15:52 ` Mike Buland
2012-04-26 18:27 ` Wayne Marshall [this message]
2012-04-26 19:02   ` Charlie Brady
2012-04-27  1:20   ` Laurent Bercot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120426202753.1cc24411@b0llix.net \
    --to=wcm@b0llix.net \
    --cc=harishbadrinath@gmail.com \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).