Re: s6 style "readiness notification" with perpd

From: Jeff <sysinit_at_yandex.com>
Date: Fri, 26 Apr 2019 17:58:56 +0200

26.04.2019, 17:27, "Laurent Bercot" <ska-supervision_at_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.
Received on Fri Apr 26 2019 - 15:58:56 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:19 UTC