supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Jeff <sysinit@yandex.com>
To: supervision <supervision@list.skarnet.org>
Subject: Re: s6 style "readiness notification" with perpd
Date: Fri, 26 Apr 2019 17:58:56 +0200	[thread overview]
Message-ID: <3257791556294336@iva5-e99a26c42780.qloud-c.yandex.net> (raw)
In-Reply-To: <emf94ce2e1-d197-4203-9413-02c7505d176f@elzian>

26.04.2019, 17:27, "Laurent Bercot" <ska-supervision@skarnet.org>:
> It doesn't matter what the number is that the service sees. As long
> as perpd creates a separate pipe for every service (which is why it
> would count against the maximum number of services it can maintain),
> it can read the notifications from every service separately.

so there is a small advantage of using an intermediary supervise
child process instead of doing it in a more integrated way directly
in the perpd parent process.

of course one can run more intances of perpd on different scandirs
should the upper limit on the number of open fds be exceeded
(which is rarely the case i guess).

> The notification-fd value used by s6-supervise is not relevant to
> s6-supervise, it's only relevant to the service. It's only used
> by s6-supervise at ./run spawning time, to tell what number the
> *child* should dup2() the notification pipe to before execing ./run,
> so the pipe is made available to the service on the fd it expects.

probably fd 3 in most cases ... 

> The supervisor itself does not use fixed fd numbers. It would be
> the same with perpd.

ok, i see.
so the perpd parent process opens a pipe(2) for every such service
and does a dup(2) after fork(2) in the child process that execs into
the service run script somehow among these lines:

...

pid_t p = 0 ;
int p [ 2 ] = { -1 } ;

pipe ( p ) ;

p = fork ()

if ( 0 == p ) {
  // child process that should execve(2) into the daemon
  ... 
  dup2 ( p [ 1 ], requested_fd ) ;
  ...
  // exec into service run script
  execve ( ... ) ;
  _exit ( 111 ) ;
} else if ( 0 < p ) {
  // parent process (perpd)
  // waitpid() for child and read(2) from p [ 0 ]
} else if ( 0 > p ) {
  // fork(2) failed
}

...

dumb question anyway, my error.



      reply	other threads:[~2019-04-26 15:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26  1:25 Jeff
2019-04-26  9:24 ` Laurent Bercot
2019-04-26 15:01   ` Jeff
2019-04-26 15:28     ` Laurent Bercot
2019-04-26 15:58       ` Jeff [this message]

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=3257791556294336@iva5-e99a26c42780.qloud-c.yandex.net \
    --to=sysinit@yandex.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).