Process group ownership

Jos Backus josb at cncdsl.com
Sat Dec 29 13:41:03 GMT 2001


    Hi Jeremy,

On Sat, Dec 29, 2001 at 01:16:25PM -0800, Jeremy Allison wrote:
> On Thu, Dec 27, 2001 at 07:47:59PM -0801, Jos Backus wrote:
> > 
> > Indeed, sorry. Would you please have a look at the patch below? It adds
> > the -F flag to {n,s}mbd telling it not to fork. This way one can run these
> > daemons under Dan Bernstein's daemontools and AIX's System Resource
> > Controller. I can supply the doc diffs as well.
> 
> Actually, this was already done in HEAD using the -i (interactive) flag so
> that's what I just added to smbd/nmbd in 2.2.3.

However, this does not work the way I need it to. source/smbd/server.c still
does a ``if(am_parent) kill(0,SIGTERM);'' so when the pgrp doesn't change
because we no longer do a setsid() because we no longer call become_daemon(),
this kill() kill's the process controller and everything else that runs under
it! The (broken, sorry) patch I submitted earlier,

    http://samba.org/samba-patches?findid=417

does exactly what -i does now, and it definitely does not work. You can close
that report for that reason, btw.

I'm trying to get the Apache folks to adopt a similar patch. Here's an exerpt
from an e-mail I sent them yesterday explaining the situation:

<quote>
In the daemontools case, the supervise program forks and its child runs
the ``run'' script, which in turn execs the daemon. So I'm assuming that the
daemon is _not_ the pgrp leader. Consider this evidence: on my FreeBSD
-current system I see the following:

    % ps -ax -o pid,ppid,pgid,command
      246     1    46 svscan /service
      273   246    46 supervise nmbd
      282   246    46 supervise smbd
    22124   273 22124 /usr/local/sbin/nmbd -F
    22127 22124 22124 /usr/local/sbin/nmbd -F
    22125   282 22125 /usr/local/sbin/smbd -F

The ``run'' script (for nmbd) is simply

    #!/bin/sh
    exec /usr/local/sbin/nmbd -F

The above output clearly shows {n,s}mbd running in their own pgrps, which is
what we want; when I down those services using ``svc -d /service/?mbd'' they
go away, without killing the members of pgrp 46. Without the -F flag/patch all  
the members of pgrp 46 do get killed, which is obviously undesirable. So I am   
really hoping that the Samba people will adopt my patch :-)
</quote>

(The other solution to this would be to not use ``kill(0,SIGTERM)'' but kill
the individual children smbd creates instead; I'm not sure how hard that would
be to implement though.)

So will you please reconsider adding my patch too?

Thanks!

> Jeremy.

-- 
Jos Backus                 _/  _/_/_/        Santa Clara, CA
                          _/  _/   _/
                         _/  _/_/_/             
                    _/  _/  _/    _/
josb at cncdsl.com     _/_/   _/_/_/            use Std::Disclaimer;




More information about the samba-technical mailing list