mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Re: Vision for new platform
Date: Sat, 9 Jun 2012 17:24:11 -0400	[thread overview]
Message-ID: <20120609212411.GA163@brightrain.aerifal.cx> (raw)
In-Reply-To: <20120609074426.496a5e13@newbook>

On Sat, Jun 09, 2012 at 07:44:26AM -0700, Isaac Dunham wrote:
> > > pid files
> > Yup, when daemon dead (or someone cut off power), there is nothing to
> > kill
> > > killall
> > Horrible and harmful
> > Maybe pgrep/pkill sucks less and will replace that horrible approach
> > to store pidfiles and believe that daemon is still running.
> > Actually systemd is more, MORE harmful than this old stuff.
> IIRC, pkill is racey--it checks the PID for a name, then kills the PID 
> (meaning that if you have almost all the processes supported running,

Almost all traditional uses of PIDs are racy and outright WRONG.
Unless you take extreme care, the *only* processes to which a PID
value is meaningful are the process itself and its parent process. The
parent process controls the lifetime of a PID; for the purposes of
robust resource management, child process PIDs should be treated
similarly to pointer's in the parent's address space: not something
you share with the outside world.

With that said, there are some legitimate ways to use PIDs elsewhere.
For instance if you have a process that never exits or crashes (i.e.
a proper robust daemon), then the only way the PID can be invalidated
is by explicitly terminating it, and assuming you only have one admin
or perform some sort of human-space synchronization with other admins
before killing anything, all is well and you can use the PID to kill
the process or send other signals (e.g. for reloading config).

There are also ways to mediate use of the PID through the parent
process, but these depend on the parent process being robust and not
exiting unexpectedly.

Where systemd is right is in deprecating pidfiles and other legacy
means of starting and stopping daemons based on searching the process
table. Where it's wrong is in putting all of this logic in pid #1
(init). A much better approach for systems that need automatic
stopping and starting of daemons would be to have a tiny
daemon-supervisor process to handle it; small systems with a very
"hands-on" admin not wanting to automate this could then skip the
supervisor daemon and start/stop manually.

Another approach would be for daemons to open unix sockets to control
their termination. The existence of the socket would reflect whether
the daemon is running, and serve as a race-free way to terminate the
current instance.

Rich


  parent reply	other threads:[~2012-06-09 21:24 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-18  1:06 Rich Felker
2012-05-18  3:11 ` Isaac Dunham
2012-05-18  3:26   ` Rich Felker
2012-05-19  1:28     ` Isaac Dunham
2012-05-18  6:07 ` Szabolcs Nagy
2012-05-21 20:05 ` aep
2012-05-21 20:17   ` Rich Felker
2012-05-21 20:51   ` nwmcsween
2012-05-21 20:59     ` Rich Felker
2012-05-21 21:18   ` Rich Felker
2012-05-21 21:51     ` aep
2012-05-21 22:25       ` Rich Felker
2012-05-22  0:53         ` aep
2012-05-22  1:54           ` Rich Felker
2012-05-22 12:55         ` Christoph Lohmann
2012-06-09 11:27 ` orc
2012-06-09 14:44   ` Isaac Dunham
2012-06-09 15:25     ` orc
2012-06-09 21:24     ` Rich Felker [this message]
2012-06-09 22:38       ` Christian Neukirchen
2012-06-10 12:53         ` Daniel Cegiełka
2012-06-10 13:22           ` Rich Felker
2012-06-10 14:52             ` orc
2012-06-10 14:55               ` orc
2012-06-10 15:13               ` Rich Felker
2012-06-10 15:51                 ` orc
2012-06-10 16:33                   ` Rich Felker
2012-06-10 17:53                     ` orc
2012-06-10 18:03                       ` Daniel Cegiełka
2012-06-10 18:26                         ` orc
2012-06-10 18:38                           ` Daniel Cegiełka
2012-06-10 18:58                             ` orc
2012-06-10 19:19                               ` Daniel Cegiełka
2012-06-10 19:33                             ` Rich Felker
2012-06-10 20:13                               ` Daniel Cegiełka
2012-06-11  7:24                                 ` orc
2012-06-11 12:54                               ` Init system (Re: [musl] Re: Vision for new platform) aep
2012-06-12  0:59                               ` Re: Vision for new platform Isaac Dunham
2012-06-12  1:48                                 ` Rich Felker
2012-06-12  5:37                                   ` idunham
2012-06-12  5:48                                     ` Kurt H Maier
2012-06-12  8:20                                       ` aep
2012-06-12 14:32                                         ` Rich Felker
2012-06-14  4:28                                       ` Isaac Dunham
2012-06-12 14:30                                     ` Rich Felker
2012-06-12  7:46                                   ` orc
2012-06-12  8:27                                     ` nwmcsween
2012-06-12  8:41                                       ` orc
2012-06-12  8:44                                     ` aep
2012-06-12  9:02                                       ` orc
2012-06-12 10:28                                         ` aep
2012-06-12 10:33                                           ` orc
2012-06-10 15:17               ` Daniel Cegiełka
2012-06-10 15:27                 ` Rich Felker
2012-06-10 15:12 ` Jeremy Huntwork
2012-06-10 18:03   ` Kurt H Maier
2012-06-10 18:15     ` Jeremy Huntwork

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=20120609212411.GA163@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).